package com.app.megaprosoft.modyimcarcare;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;

import com.megaprosoft.modyimcarcare.R;

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class HoleActivity_edit extends Activity {
	
	connect con = new connect(); 
	DecimalFormat df = new DecimalFormat("#,###,##0.00");	
	ResultSet rs;
	TextView	TextSum,et1,et2,et3,et4,et5,et6,et7,et8,et9,et10,et11,et12,et13,et14,et15,SumAmount;
	CheckBox 	c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15;
	double a,b,c,d,e,f,g,h,ii,jj,k,l,m,n,o,p,subSum = 0,finalSum = 0,amount = 0 ;
	int timeSum = 0;
	ResultSet rs2;
	EditText	disc,prom;
	Button 		btn1,Sum,edit;
	String list1="",list2="",list3="",list4="",list5="",list6="",list7="",list8="",list9="",
			list10="",list11="",list12="",list13="",list14="",list15="",list16="",list17="";
	EditText orther1,orther2,orther3,disBTH;
    private int mYear;
    private int mMonth;
    private int mDay;
    
    String checkOrther1 = "";
    
    ArrayList<String> Dis = new ArrayList<String>();
    
    Spinner spnDis;
    
    int amount1,amount2,amount3,amount4,amount5,amount6,amount7,amount9,amount10,amount11,amount12,amount14;
	
	String price1="",price2="",price3="",price4="",price5="",price6="",price7="",price8="",price9="",
			price10="",price11="",price12="",price13="",price14="",price15="",price16="",price17="";
	
	int t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;

	String DiscountNameEDT,DisCt,sumDisc,sumDisBTH,sumDiscNull,sumDisBTHNull,VIPcode,id,addHole ,ServiceIDsent;

	Spinner spn1,spn2,spn3,spn4,spn5,spn6,spn7,spn8,spn9,spn10,spn11,spn12,spn13,spn14;
	String str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11,str12,str13,str14;	
	
	ArrayList<String> price = new ArrayList<String>();
	ArrayList<String> name = new ArrayList<String>();
	ArrayList<String> time = new ArrayList<String>();
	
	ArrayList<String> Gearprice = new ArrayList<String>();
	ArrayList<String> Gearname = new ArrayList<String>();
	ArrayList<String> Geartime = new ArrayList<String>();
	
	ArrayList<String> Sprocketsprice = new ArrayList<String>();
	ArrayList<String> Sprocketsname = new ArrayList<String>();
	ArrayList<String> Sprocketstime = new ArrayList<String>();
	
	ArrayList<String> GearOilAutoprice = new ArrayList<String>();
	ArrayList<String> GearOilAutoname = new ArrayList<String>();
	ArrayList<String> GearOilAutotime = new ArrayList<String>();
	
	ArrayList<String> SteeringWheelprice = new ArrayList<String>();
	ArrayList<String> SteeringWheelname = new ArrayList<String>();
	ArrayList<String> SteeringWheeltime = new ArrayList<String>();
	
	ArrayList<String> withinprice = new ArrayList<String>();
	ArrayList<String> withinname = new ArrayList<String>();
	ArrayList<String> withintime = new ArrayList<String>();
	
	ArrayList<String> liquorprice = new ArrayList<String>();
	ArrayList<String> liquorname = new ArrayList<String>();
	ArrayList<String> liquortime = new ArrayList<String>();
	
	ArrayList<String> boilerprice = new ArrayList<String>();
	ArrayList<String> boilername = new ArrayList<String>();
	ArrayList<String> boilertime = new ArrayList<String>();
	

	ArrayList<String> brakeprice = new ArrayList<String>();
	ArrayList<String> brakename = new ArrayList<String>();
	ArrayList<String> braketime = new ArrayList<String>();
	
	ArrayList<String> filterprice = new ArrayList<String>();
	ArrayList<String> filtername = new ArrayList<String>();
	ArrayList<String> filtertime = new ArrayList<String>();
	
	ArrayList<String> filterAirprice = new ArrayList<String>();
	ArrayList<String> filterAirname = new ArrayList<String>();
	ArrayList<String> filterAirtime = new ArrayList<String>();
	
	ArrayList<String> amountOne = new ArrayList<String>();
	ArrayList<String> amountGear = new ArrayList<String>();
	ArrayList<String> amountSprockets = new ArrayList<String>();
	ArrayList<String> amountbrake = new ArrayList<String>();
	
	ArrayList<String> amountGearOilAuto = new ArrayList<String>();
	ArrayList<String> amountSteeringWheel = new ArrayList<String>();
	ArrayList<String> amountwithin = new ArrayList<String>();
	ArrayList<String> amountboiler= new ArrayList<String>();
	ArrayList<String> amountgrease= new ArrayList<String>();
	ArrayList<String> amountliquor= new ArrayList<String>();
	ArrayList<String> amountcompress= new ArrayList<String>();
	ArrayList<String> amountcolor= new ArrayList<String>();
	ArrayList<String> amountfilter = new ArrayList<String>();
	ArrayList<String> amountfilterAir = new ArrayList<String>();
	
	AutoCompleteTextView textmotorOil;
	AutoCompleteTextView textGearOil;
	AutoCompleteTextView textSprocketsOil;
	
	AutoCompleteTextView textGearOilAuto;
	AutoCompleteTextView textSteeringWheel;
	AutoCompleteTextView textwithin;
	AutoCompleteTextView textboiler;
	
	AutoCompleteTextView textbrake;
	AutoCompleteTextView textfilter;
	AutoCompleteTextView textliquor;
	AutoCompleteTextView textfilterAir;
	
	
	String NameInput,company;
	 String getCarIDEDT;	
	   String  ServiceIDEDT;	
	   String RegisterIDEDT;
	   String  TypeIDEDT;
	   String  CarGroupIDEDT; 
	   String idDataService;
	   
	   String[] arr ;
	   String[] arr2 ;
	   
	   public static boolean CHECH_ADD = true; 
		public static final int REQUEST_CODE = 1;  
		
		String timeSer,sumSer,listSer,priceSer;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		setContentView(R.layout.activity_hole_edit);
		
		NameInput = getIntent().getExtras().getString("name");
		company = getIntent().getExtras().getString("CompanyS");
		addHole = getIntent().getExtras().getString("addHole");

		
		c15 = ( CheckBox ) this.findViewById ( R.id.check15);	
		 
		 et15 = ( EditText ) this.findViewById ( R.id.result15);
		 et15.setEnabled(false);
		 
		 orther1 = ( EditText ) this.findViewById ( R.id.orther1);
		 orther1.setEnabled(false);
		
		
		
		 c1 = ( CheckBox ) this.findViewById ( R.id.check1);			
		 et1 = ( TextView ) this.findViewById ( R.id.result1);
		 
		 c2 = ( CheckBox ) this.findViewById ( R.id.check2);			
		 et2 = ( TextView ) this.findViewById ( R.id.result2);
		 
		 c3 = ( CheckBox ) this.findViewById ( R.id.check3);			
		 et3 = ( TextView ) this.findViewById ( R.id.result3);
		
		 c4 = ( CheckBox ) this.findViewById ( R.id.check4);			
		 et4 = ( TextView ) this.findViewById ( R.id.result4);
		 
		 c5 = ( CheckBox ) this.findViewById ( R.id.check5);			
		 et5 = ( TextView ) this.findViewById ( R.id.result5);
		 
		 c6 = ( CheckBox ) this.findViewById ( R.id.check6);			
		 et6 = ( TextView ) this.findViewById ( R.id.result6);
		 
		 c7 = ( CheckBox ) this.findViewById ( R.id.check7);			
		 et7 = ( TextView ) this.findViewById ( R.id.result7);
		 
		 c8 = ( CheckBox ) this.findViewById ( R.id.check8);			
		 et8 = ( TextView ) this.findViewById ( R.id.result8);
		 
		 c9 = ( CheckBox ) this.findViewById ( R.id.check9);			
		 et9 = ( TextView ) this.findViewById ( R.id.result9);
		 
		 c10 = ( CheckBox ) this.findViewById ( R.id.check10);			
		 et10 = ( TextView ) this.findViewById ( R.id.result10);
		 
		 c11= ( CheckBox ) this.findViewById ( R.id.check11);			
		 et11 = ( TextView ) this.findViewById ( R.id.result11);
		 
		 c12 = ( CheckBox ) this.findViewById ( R.id.check12);			
		 et12 = ( TextView ) this.findViewById ( R.id.result12);
		 
		 c13 = ( CheckBox ) this.findViewById ( R.id.check13);			
		 et13 = ( TextView ) this.findViewById ( R.id.result13);
		 
		 c14 = ( CheckBox ) this.findViewById ( R.id.check14);			
		 et14 = ( TextView ) this.findViewById ( R.id.result14);
		 
		 textmotorOil = (AutoCompleteTextView) findViewById(R.id.Months);
		 textmotorOil.setEnabled(false);
		 textGearOil = (AutoCompleteTextView) findViewById(R.id.Auto2);   
		 textGearOil.setEnabled(false);
		 textSprocketsOil = (AutoCompleteTextView) findViewById(R.id.Auto3);
		 textSprocketsOil.setEnabled(false);
		 
		 textGearOilAuto = (AutoCompleteTextView) findViewById(R.id.Auto4);
		 textGearOilAuto.setEnabled(false);
		 
		 textSteeringWheel = (AutoCompleteTextView) findViewById(R.id.Auto5);
		 textSteeringWheel.setEnabled(false);
		 
		 textwithin = (AutoCompleteTextView) findViewById(R.id.Auto6);
		 textwithin.setEnabled(false);
		 
		 textboiler = (AutoCompleteTextView) findViewById(R.id.Auto7);
		 textboiler.setEnabled(false);
		 
		 textliquor = (AutoCompleteTextView) findViewById(R.id.Auto12);
		 textliquor.setEnabled(false);
		 
		 
		 textbrake = (AutoCompleteTextView) findViewById(R.id.Auto9);
		 textbrake.setEnabled(false);
		 textfilter = (AutoCompleteTextView) findViewById(R.id.Auto10);
		 textfilter.setEnabled(false);
		 textfilterAir = (AutoCompleteTextView) findViewById(R.id.Auto11);
		 textfilterAir.setEnabled(false);
		 
		 
		
		 
		 
		 TextSum = (TextView) findViewById(R.id.Sum);
		 Sum = (Button) findViewById(R.id.ButtonSum);
		 edit = (Button) findViewById(R.id.btnES);
		 
		 disc = (EditText) findViewById(R.id.discount);
		 disBTH = (EditText) findViewById(R.id.disBTH);
		 SumAmount = ( TextView ) this.findViewById ( R.id.SumAmount );
		 
		 sumDisc = "0";
	 	 sumDisBTH = "0";
	 	 
	 	 prom = (EditText) findViewById(R.id.VIPcode);	
		 
		 btn1 = (Button) findViewById(R.id.button1);
		 
		 spn1 = (Spinner) findViewById(R.id.spin1);
		 spn1.setEnabled(false);
		 
		 spn2 = (Spinner) findViewById(R.id.spin2);
		 spn2.setEnabled(false);
		 
		 spn3 = (Spinner) findViewById(R.id.spin3);
		 spn3.setEnabled(false);
		 
		 spn4 = (Spinner) findViewById(R.id.spin4);
		 spn4.setEnabled(false);
		 
		 spn5 = (Spinner) findViewById(R.id.spin5);
		 spn5.setEnabled(false);
		 
		 spn6 = (Spinner) findViewById(R.id.spin6);
		 spn6.setEnabled(false);
		 
		 spn7 = (Spinner) findViewById(R.id.spin7);
		 spn7.setEnabled(false);
		 
		 spn8 = (Spinner) findViewById(R.id.spin8);
		 spn8.setEnabled(false);
		 
		 spn9 = (Spinner) findViewById(R.id.spin9);
		 spn9.setEnabled(false);
		 
		 spn10 = (Spinner) findViewById(R.id.spin10);
		 spn10.setEnabled(false);
		 
		 spn11 = (Spinner) findViewById(R.id.spin11);
		 spn11.setEnabled(false);
		 
		 spn12 = (Spinner) findViewById(R.id.spin12);
		 spn12.setEnabled(false);
		 
		 spn13 = (Spinner) findViewById(R.id.spin13);
		 spn13.setEnabled(false);
		 
		 spn14 = (Spinner) findViewById(R.id.spin14);
		 spn14.setEnabled(false);
		 
		 
        
		
		
		 id = getIntent().getExtras().getString("IntentID");	
		 getCarIDEDT = getIntent().getExtras().getString("getCarID");		
		 ServiceIDEDT = getIntent().getExtras().getString("ServiceID");	
		 RegisterIDEDT = getIntent().getExtras().getString("RegisterID");
		 TypeIDEDT = getIntent().getExtras().getString("TypeID");
		 CarGroupIDEDT = getIntent().getExtras().getString("CarGroupID");
		 
	
		 
		   
		   System.out.println(getCarIDEDT);
		   System.out.println(ServiceIDEDT);
		   System.out.println(RegisterIDEDT);
		   System.out.println(TypeIDEDT);
		   System.out.println(CarGroupIDEDT);
		   
		   
		    motorOil(); 
			GearOil();
			SprocketsOil();
			GearOilAuto();
			SteeringWheel();
			within();
			boiler();
			grease();
			brake();
			filter();
			filterAir();
			liquor();
			compress();
			color();
		   
		   
		   String sql = "SELECT id AS DataServiceID "+
				      ",ServiceID "+
				      ",TypeID "+
				      ",List "+
				      ",price "+
				      ",VIPcode "+
				      ",Discount "+
				      ",amount "+
				      ",Sum "+
				      ",sumTime "+
				      ",date "+
				      ",DiscountName "+
				      ",PriceBTH "+
				      ",checkOrther "+
				  "FROM DataService "+
				  "WHERE ServiceID = "+ServiceIDEDT+" ";
		   
		   
		   String listEDT = "";
			String DiscountEDT = "";
			String SumEDT = "";
			DiscountNameEDT = "";
			String amountEDT = "";
			String VIPcodeEDT = "";
			String PriceBTHEDT = "";
			String PriceEDT = "";
			String check = "";
					rs = con.selectData(sql);		   
					try {
						//while(rs.next()){ 
						    rs.next();
						    listEDT = rs.getString("List"); 
						    DiscountEDT	= rs.getString("Discount"); 
						    SumEDT = rs.getString("Sum"); 
						    idDataService = rs.getString("DataServiceID"); 
						    PriceEDT = rs.getString("price");
						    DiscountNameEDT = rs.getString("DiscountName");
							amountEDT = rs.getString("amount"); 
							VIPcodeEDT = rs.getString("VIPcode"); 
							PriceBTHEDT = rs.getString("PriceBTH"); 
							check = rs.getString("checkOrther"); 
						//}
					} catch (SQLException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					} 
					
					arr = listEDT.split(",");
					arr2 = PriceEDT.split(",");

					
					orther1();
					SumAmount.setText(amountEDT);
					TextSum.setText(SumEDT);
					
					
					if(addHole.equals("addHole")){
										
						
						prom.setEnabled(false);
						disc.setEnabled(false);
						disBTH.setEnabled(false);
						edit.setEnabled(false);			
										
										
									}else{	
										
										
									selectDis();
									prom.setText(VIPcodeEDT);
									disc.setText(DiscountEDT);
									disBTH.setText(PriceBTHEDT);
									
									
									
									edit.setOnClickListener(new View.OnClickListener() {
										@Override
										public void onClick(View v) {
											
											CHECH_ADD = false;
											
										 String sql = "SELECT getCar.id AS getCarID "+
										     ",getCar.ServiceID AS ServiceID "+
										     ",getCar.RegisterID AS RegisterID "+
										     ",DataService.TypeID AS TypeID "+
										     ",CustomerCar.CarGroup AS CarGroup "+
										 
										 "FROM getCar "+ 
										 
										 "LEFT JOIN DataService "+
										 "ON getCar.ServiceID = DataService.ServiceID "+
										 
										 "LEFT JOIN CustomerCar "+
										 "ON getCar.ServiceID = CustomerCar.ServiceID "+
										 
										 "WHERE getCar.ServiceID = "+id+" ";
										 
										String 	getCarID = "";	  
										String 	ServiceID = "";
										String 	RegisterID = "";
										String 	getCarIDtoEdit = "";
										String  CarGroupID = "";
											rs = con.selectData(sql);		   
										try {
											//while(rs.next()){ 
											    rs.next();
											    getCarID = rs.getString("getCarID"); 
												ServiceID = rs.getString("ServiceID"); 
												RegisterID = rs.getString("RegisterID"); 
												getCarIDtoEdit = rs.getString("TypeID"); 
												CarGroupID = rs.getString("CarGroup"); 
												
											if(getCarIDtoEdit.equals("1")){	
												Intent goCheck = new Intent(HoleActivity_edit.this,services_edit.class);
											    goCheck.putExtra("getCarID", getCarID);
												goCheck.putExtra("ServiceID", ServiceID);
												goCheck.putExtra("RegisterID", RegisterID);
												goCheck.putExtra("TypeID", getCarIDtoEdit);
												goCheck.putExtra("CarGroupID", CarGroupID);
												goCheck.putExtra("IntentID", id);
												goCheck.putExtra("name", NameInput);
												goCheck.putExtra("CompanyS", company);
												goCheck.putExtra("addHole", "addHole");
												startActivityForResult(goCheck, REQUEST_CODE);	
											}	
											
											else{
												Intent goCheck = new Intent(HoleActivity_edit.this,services_edit.class);
											    goCheck.putExtra("getCarID", getCarID);
												goCheck.putExtra("ServiceID", ServiceID);
												goCheck.putExtra("RegisterID", RegisterID);
												goCheck.putExtra("TypeID", getCarIDtoEdit);
												goCheck.putExtra("CarGroupID", CarGroupID);
												goCheck.putExtra("IntentID", id);
												goCheck.putExtra("name", NameInput);
												goCheck.putExtra("CompanyS", company);
												goCheck.putExtra("addSer", "addSer");
												startActivityForResult(goCheck, REQUEST_CODE);	
											}
												
											//}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
											Toast.makeText(HoleActivity_edit.this,"Ho!!!"+id, Toast.LENGTH_LONG).show();
										}    
										
											
											
										
										
										}
										});	
				 									
									}
									
					
					for(int i = 0;i<arr.length;i++){
						System.out.println("list =   "+arr.length+"======"+arr[i]);
						//System.out.println("price =   "+arr2.length+"======"+arr2[i]);
						
					}
	    			
					
					
					Toast.makeText(HoleActivity_edit.this, "Service : "+ServiceIDEDT, Toast.LENGTH_SHORT).show();
					
		//===================================CHECK1======================================================================	
				//1
					 rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201309160001' ");
					 try {
							while(rs.next()){          
							
								name.add(rs.getString("ItemName"));	
								price.add(rs.getString("LastBuyPrice"));	
								time.add(rs.getString("Duration"));	
								
								}
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					 
			//2		 
					 rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201309160002' ");		   

						try {
							while(rs.next()){          
								Gearprice.add(rs.getString("LastBuyPrice"));	
								Gearname.add(rs.getString("ItemName"));	
								Geartime.add(rs.getString("Duration"));
								}
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						
				//3		
						 rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110001' ");		   
									try {
										while(rs.next()){          
											Sprocketsprice.add(rs.getString("LastBuyPrice"));	
											Sprocketsname.add(rs.getString("ItemName"));	
											Sprocketstime.add(rs.getString("Duration"));
											}
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}
									
				//4
									 rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110012' ");		   
										try {
											while(rs.next()){          
												GearOilAutoprice.add(rs.getString("LastBuyPrice"));	
												GearOilAutoname.add(rs.getString("ItemName"));	
												GearOilAutotime.add(rs.getString("Duration"));
												}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
										}
										
									
				//5
										rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110013' ");		   
										try {
											while(rs.next()){          
												SteeringWheelprice.add(rs.getString("LastBuyPrice"));	
												SteeringWheelname.add(rs.getString("ItemName"));	
									            SteeringWheeltime.add(rs.getString("Duration"));
												}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
										}
										
										
				//6
										rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110014' ");		   
										try {
											while(rs.next()){          
												withinprice.add(rs.getString("LastBuyPrice"));	
												withinname.add(rs.getString("ItemName"));	
												withintime.add(rs.getString("Duration"));
												}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
										}
										
			//7
										rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110015' ");		   
										try {
											while(rs.next()){          
												boilerprice.add(rs.getString("LastBuyPrice"));	
												boilername.add(rs.getString("ItemName"));	
												boilertime.add(rs.getString("Duration"));
												}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
										}						
										
				//9
						 rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201309160003' ");		   

										try {
											while(rs.next()){          
												brakeprice.add(rs.getString("LastBuyPrice"));	
												brakename.add(rs.getString("ItemName"));	
												braketime.add(rs.getString("Duration"));
												}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
										} 
										
				  //10
					 rs = con.selectData("SELECT *,ItemCode+' '+ItemName AS ItemCo FROM Item WHERE ItemGroupCode = '105201309160011' ");		   

										try {
												while(rs.next()){          
													filterprice.add(rs.getString("LastBuyPrice"));	
													filtername.add(rs.getString("ItemCo"));	
													filtertime.add(rs.getString("Duration"));
													}
											} catch (SQLException e) {
												// TODO Auto-generated catch block
												e.printStackTrace();
											}
											
					//11
				    rs = con.selectData("SELECT *,ItemCode+' '+ItemName AS ItemCo FROM Item WHERE ItemGroupCode = '105201309160008' ");		   


											try {
												while(rs.next()){          
													filterAirprice.add(rs.getString("LastBuyPrice"));	
													filterAirname.add(rs.getString("ItemCo"));	
													filterAirtime.add(rs.getString("Duration"));	
													}
											} catch (SQLException e) {
												// TODO Auto-generated catch block
												e.printStackTrace();
											} 
				//12
										    rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110016' ");		   

										    try {
												while(rs.next()){          
													liquorprice.add(rs.getString("LastBuyPrice"));	
													liquorname.add(rs.getString("ItemName"));	
													liquortime.add(rs.getString("Duration"));	
													}
												} catch (SQLException e) {
														// TODO Auto-generated catch block
													e.printStackTrace();
												} 
																	
										
					
					for(int i = 0 ; i<arr.length ; i++){
						
						for(int j = 0 ; j<name.size() ; j++){
							
						  if(arr[i].equals(name.get(j))){
							
						
						    c1.setChecked(true);
							textmotorOil.setEnabled(true);
					        spn1.setEnabled(true);
							
					 
							
							ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, name);
							textmotorOil.setThreshold(1);
							textmotorOil.setAdapter(adapter);
							textmotorOil.setText(name.get(j).toString());
							
							    str1 = price.get(j).toString();
							    list1 = name.get(j).toString()+",";
							    price1 = arr2[i]+",";
							    et1.setText(df.format(Double.parseDouble(arr2[i])));
								t1 = Integer.parseInt(time.get(j).toString());
								a = Double.parseDouble(arr2[i]);
								
							//===================== Select amount=============================================== 	
						    
							    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(str1);
							    amount1 = (int) temp;
							    Log.i("amount1 = ",""+amount1);
						
								
								for(int ii = 1 ; ii<=10 ; ii++){
									amountOne.add(String.valueOf(ii));
									}
								
								    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountOne);
									empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
									spn1.setAdapter(empolyeeAdapter);
									if(amount1 == 0){
										amount1 = 1;
									}
									spn1.setSelection(amount1-1);
									
									double div = Double.parseDouble(amountOne.get(amount1-1));
					            	double ans = div * Double.parseDouble(str1);

				 						et1.setText(df.format(ans));
										price1 = ans+",";
										a = ans;
										
										spn1.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long ll) { 
								          	// TODO Auto-generated method stub
								            	double div = Double.parseDouble(amountOne.get(i));
								            	double ans = div * Double.parseDouble(str1);

													et1.setText(df.format(ans));
													price1 = ans+",";
													list1 = textmotorOil.getText().toString()+",";
													a = ans;
													 
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub

											} 
						
							      });
								//==================================================================
								
									   textmotorOil.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
										
							            public void onItemSelected(AdapterView<?> adapterView, 
							          	View view, int i, long l) { 
							          	// TODO Auto-generated method stub    	
							            	}
							            public void onNothingSelected(AdapterView<?> arg0) {
											// TODO Auto-generated method stub
							            	InputMethodManager imm = (InputMethodManager) getSystemService(
							                        INPUT_METHOD_SERVICE);
							                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
										} 
					
						      });
						            textmotorOil.setOnItemClickListener(new  OnItemClickListener(){

										@Override
										public void onItemClick(
												AdapterView<?> arg0,
												View arg1, int i,
												long arg3) {
											// TODO Auto-generated method stub
											spn1.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long ll) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountOne.get(i));
									            	double ans = div * Double.parseDouble(str1);

														et1.setText(df.format(ans));
														price1 = ans+",";
														a = ans;
														list1 = textmotorOil.getText().toString()+",";
														 
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
	
										}
	
						            });

						}
						 } 
						
						
						for(int j = 0 ; j<Gearname.size() ; j++){
							
							  if(arr[i].equals(Gearname.get(j))){
								
							
								c2.setChecked(true);
								textGearOil.setEnabled(true);
						        spn2.setEnabled(true);
								
						 
								
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, Gearname);
								textGearOil.setThreshold(1);
								textGearOil.setAdapter(adapter);
								textGearOil.setText(Gearname.get(j).toString());
								
									str2 = Gearprice.get(j).toString();
								    list2 = arr2[i]+",";
								    price2 = arr2[i]+",";
								    et2.setText(df.format(Double.parseDouble(arr2[i])));
									t2 = Integer.parseInt(Geartime.get(j).toString());
									b = Double.parseDouble(arr2[i]);
									
								//===================== Select amount=============================================== 	
							    
								    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(Gearprice.get(j).toString());
								    amount2 = (int) temp;
								    Log.i("amount2 = ",""+amount2);
							
									
									for(int ii = 1 ; ii<=10 ; ii++){
										amountGear.add(String.valueOf(ii));
										}
									
									    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountGear);
										empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
										spn2.setAdapter(empolyeeAdapter);
										if(amount2 == 0){
											amount2 = 1;
										}
										spn2.setSelection(amount2-1);
										
										double div = Double.parseDouble(amountGear.get(amount2-1));
						            	double ans = div * Double.parseDouble(str2);

					 						et2.setText(df.format(ans));
											price2 = ans+",";
											b = ans;
											
											spn2.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long ll) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountGear.get(i));
									            	double ans = div * Double.parseDouble(str2);

														et2.setText(df.format(ans));
														price2 = ans+",";
														b = ans;
														list2 = textGearOil.getText().toString()+",";
														 
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
									//==================================================================
									
											textGearOil.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long l) { 
								          	// TODO Auto-generated method stub    	
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub
								            	InputMethodManager imm = (InputMethodManager) getSystemService(
								                        INPUT_METHOD_SERVICE);
								                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
											} 
						
							      });
										   textGearOil.setOnItemClickListener(new  OnItemClickListener(){

											@Override
											public void onItemClick(
													AdapterView<?> arg0,
													View arg1, int i,
													long arg3) {
												// TODO Auto-generated method stub
												spn2.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long ll) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountGear.get(i));
										            	double ans = div * Double.parseDouble(str2);

															et2.setText(df.format(ans));
															price2 = ans+",";
															b = ans;
															list2 = textGearOil.getText().toString()+",";
															 
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });

											}

							            });
							}
							 } 
						
						
						
						for(int j = 0 ; j<Sprocketsname.size() ; j++){
							
							  if(arr[i].equals(Sprocketsname.get(j))){
								
							
								   c3.setChecked(true);
									textSprocketsOil.setEnabled(true);
						           spn3.setEnabled(true);
								
						 
								
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, Sprocketsname);
								textSprocketsOil.setThreshold(1);
								textSprocketsOil.setAdapter(adapter);
								textSprocketsOil.setText(Sprocketsname.get(j).toString());
								
									str3 = Sprocketsprice.get(j).toString();
								    list3 = arr2[i]+",";
								    price3 = arr2[i]+",";
								    et3.setText(df.format(Double.parseDouble(arr2[i])));
									t3 = Integer.parseInt(Sprocketstime.get(j).toString());
									c = Double.parseDouble(arr2[i]);

									
								//===================== Select amount=============================================== 	
							    
								    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(Sprocketsprice.get(j).toString());
								    amount3 = (int) temp;
								    Log.i("amount3 = ",""+amount3);
								  
							
									
									for(int ii = 1 ; ii<=10 ; ii++){
										amountSprockets.add(String.valueOf(ii));
										}
									
									    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountSprockets);
										empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
										spn3.setAdapter(empolyeeAdapter);
										if(amount3 == 0){
											amount3 = 1;
										}
										spn3.setSelection(amount3-1);
										
										double div = Double.parseDouble(amountSprockets.get(amount3-1));
						            	double ans = div * Double.parseDouble(str3);

					 						et3.setText(df.format(ans));
											price3 = ans+",";
											c = ans;
											
											spn3.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long ll) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountSprockets.get(i));
									            	double ans = div * Double.parseDouble(str3);

														et3.setText(df.format(ans));
														price3 = ans+",";
														c = ans;
														list3 = textSprocketsOil.getText().toString()+",";
														 
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
									//==================================================================
									
											textSprocketsOil.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long l) { 
								          	// TODO Auto-generated method stub    	
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub
								            	InputMethodManager imm = (InputMethodManager) getSystemService(
								                        INPUT_METHOD_SERVICE);
								                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
											} 
						
							      });
											textSprocketsOil.setOnItemClickListener(new  OnItemClickListener(){

											@Override
											public void onItemClick(
													AdapterView<?> arg0,
													View arg1, int i,
													long arg3) {
												// TODO Auto-generated method stub
												spn3.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long ll) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountSprockets.get(i));
										            	double ans = div * Double.parseDouble(str3);

															et3.setText(df.format(ans));
															price3 = ans+",";
															c = ans;
															list3 = textSprocketsOil.getText().toString()+",";
															 
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });

											}

							            });
							}
							 } 
						
						
						
						//==========================check 4 ======================================
						
						
						 
			
						for(int j = 0 ; j<GearOilAutoname.size() ; j++){
							
							  if(arr[i].equals(GearOilAutoname.get(j))){
								
							
								   c4.setChecked(true);
								   textGearOilAuto.setEnabled(true);
						           spn4.setEnabled(true);
								
						 
								
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, GearOilAutoname);
								textGearOilAuto.setThreshold(1);
								textGearOilAuto.setAdapter(adapter);
								textGearOilAuto.setText(GearOilAutoname.get(j).toString());
								
									str4 = GearOilAutoprice.get(j).toString();
								    list4 = arr2[i]+",";
								    price4 = arr2[i]+",";
								    et4.setText(df.format(Double.parseDouble(arr2[i])));
									t4 = Integer.parseInt(GearOilAutotime.get(j).toString());
									d = Double.parseDouble(arr2[i]);

									
								//===================== Select amount=============================================== 	
							    
								    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(GearOilAutoprice.get(j).toString());
								    amount4 = (int) temp;
								    Log.i("amount4 = ",""+amount4);
								  
							
									
									for(int ii = 1 ; ii<=10 ; ii++){
										amountGearOilAuto.add(String.valueOf(ii));
										}
									
									    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountGearOilAuto);
										empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
										spn4.setAdapter(empolyeeAdapter);
										if(amount4 == 0){
											amount4 = 1;
										}
										spn4.setSelection(amount4-1);
										
										double div = Double.parseDouble(amountGearOilAuto.get(amount4-1));
						            	double ans = div * Double.parseDouble(str4);

					 						et4.setText(df.format(ans));
											price4 = ans+",";
											d = ans;
											
											spn4.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long ll) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountGearOilAuto.get(i));
									            	double ans = div * Double.parseDouble(str4);

														et4.setText(df.format(ans));
														price4 = ans+",";
														d = ans;
														list4 = textGearOilAuto.getText().toString()+",";
														 
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
									//==================================================================
									
											textGearOilAuto.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long l) { 
								          	// TODO Auto-generated method stub    	
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub
								            	InputMethodManager imm = (InputMethodManager) getSystemService(
								                        INPUT_METHOD_SERVICE);
								                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
											} 
						
							      });
											textGearOilAuto.setOnItemClickListener(new  OnItemClickListener(){

											@Override
											public void onItemClick(
													AdapterView<?> arg0,
													View arg1, int i,
													long arg3) {
												// TODO Auto-generated method stub
												spn4.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long ll) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountGearOilAuto.get(i));
										            	double ans = div * Double.parseDouble(str4);

															et4.setText(df.format(ans));
															price4 = ans+",";
															list4 = textGearOilAuto.getText().toString()+",";
															d = ans;
															 
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });

											}

							            });
							}
							 } 
						
						
						
						//==========================check 5 ======================================
												 
						
						for(int j = 0 ; j<SteeringWheelname.size() ; j++){
							
							  if(arr[i].equals(SteeringWheelname.get(j))){
								
							
								   c5.setChecked(true);
								   textSteeringWheel.setEnabled(true);
						           spn5.setEnabled(true);
								
						 
								
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, SteeringWheelname);
								textSteeringWheel.setThreshold(1);
								textSteeringWheel.setAdapter(adapter);
								textSteeringWheel.setText(SteeringWheelname.get(j).toString());
								
									str5 = SteeringWheelprice.get(j).toString();
								    list5 = arr2[i]+",";
								    price5 = arr2[i]+",";
								    et5.setText(df.format(Double.parseDouble(arr2[i])));
									t5 = Integer.parseInt(SteeringWheeltime.get(j).toString());
									e = Double.parseDouble(arr2[i]);

									
								//===================== Select amount=============================================== 	
							    
								    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(SteeringWheelprice.get(j).toString());
								    amount5 = (int) temp;
								    Log.i("amount5 = ",""+amount5);
								  
							
									
									for(int ii = 1 ; ii<=10 ; ii++){
										amountSteeringWheel.add(String.valueOf(ii));
										}
									
									    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountSteeringWheel);
										empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
										spn5.setAdapter(empolyeeAdapter);
										if(amount5 == 0){
											amount5 = 1;
										}
										spn5.setSelection(amount5-1);
										
										double div = Double.parseDouble(amountSteeringWheel.get(amount5-1));
						            	double ans = div * Double.parseDouble(str5);

					 						et5.setText(df.format(ans));
											price5 = ans+",";
											e = ans;
											
											spn5.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long ll) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountSteeringWheel.get(i));
									            	double ans = div * Double.parseDouble(str5);

														et5.setText(df.format(ans));
														price5 = ans+",";
														list5 = textSteeringWheel.getText().toString()+",";
														e = ans;
														 
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
									//==================================================================
									
											textSteeringWheel.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long l) { 
								          	// TODO Auto-generated method stub    	
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub
								            	InputMethodManager imm = (InputMethodManager) getSystemService(
								                        INPUT_METHOD_SERVICE);
								                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
											} 
						
							      });
											textSteeringWheel.setOnItemClickListener(new  OnItemClickListener(){

											@Override
											public void onItemClick(
													AdapterView<?> arg0,
													View arg1, int i,
													long arg3) {
												// TODO Auto-generated method stub
												spn5.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long ll) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountSteeringWheel.get(i));
										            	double ans = div * Double.parseDouble(str5);
										            		
															et5.setText(df.format(ans));
															price5 = ans+",";
															list5 = textSteeringWheel.getText().toString()+",";
															e = ans;
															 
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });

											}

							            });
							}
							  
							  
							 } 
						
						
                   //==========================check 6 ======================================
												 
						
						for(int j = 0 ; j<withinname.size() ; j++){
							
							  if(arr[i].equals(withinname.get(j))){
								
							
								   c6.setChecked(true);
								   textwithin.setEnabled(true);
						           spn6.setEnabled(true);
								
						 
								
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, withinname);
								textwithin.setThreshold(1);
								textwithin.setAdapter(adapter);
								textwithin.setText(withinname.get(j).toString());
								
									str6 = withinprice.get(j).toString();
								    list6 = arr2[i]+",";
								    price6 = arr2[i]+",";
								    et6.setText(df.format(Double.parseDouble(arr2[i])));
									t6 = Integer.parseInt(withintime.get(j).toString());
									f = Double.parseDouble(arr2[i]);

									
								//===================== Select amount=============================================== 	
							    
								    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(withinprice.get(j).toString());
								    amount6 = (int) temp;
								    Log.i("amount6 = ",""+amount6);
								  
							
									
									for(int ii = 1 ; ii<=10 ; ii++){
										amountwithin.add(String.valueOf(ii));
										}
									
									    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountwithin);
										empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
										spn6.setAdapter(empolyeeAdapter);
										if(amount6 == 0){
											amount6 = 1;
										}
										spn6.setSelection(amount6-1);
										
										double div = Double.parseDouble(amountwithin.get(amount6-1));
						            	double ans = div * Double.parseDouble(str6);

					 						et6.setText(df.format(ans));
											price6 = ans+",";
											f = ans;
											
											spn6.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long ll) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountwithin.get(i));
									            	double ans = div * Double.parseDouble(str6);

														et6.setText(df.format(ans));
														price6 = ans+",";
														list6 = textwithin.getText().toString()+",";
														f = ans;
														 
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							 
								      });
									//==================================================================
									
											textwithin.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long l) { 
								          	// TODO Auto-generated method stub    	
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub
								            	InputMethodManager imm = (InputMethodManager) getSystemService(
								                        INPUT_METHOD_SERVICE);
								                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
											} 
						
							      });
											textwithin.setOnItemClickListener(new  OnItemClickListener(){

											@Override
											public void onItemClick(
													AdapterView<?> arg0,
													View arg1, int i,
													long arg3) {
												// TODO Auto-generated method stub
												spn6.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long ll) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountwithin.get(i));
										            	double ans = div * Double.parseDouble(str6);
										            		
															et6.setText(df.format(ans));
															price6 = ans+",";
															list6 = textwithin.getText().toString()+",";
															f = ans;
															 
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });

											}

							            });
							}
							  
							  
							 } 
						
						
		                   //==========================check 7 ======================================
						 
						
								for(int j = 0 ; j<boilername.size() ; j++){
									
									  if(arr[i].equals(boilername.get(j))){
										
									
										   c7.setChecked(true);
										   textboiler.setEnabled(true);
								           spn7.setEnabled(true);
										
								 
										
										ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, boilername);
										textboiler.setThreshold(1);
										textboiler.setAdapter(adapter);
										textboiler.setText(boilername.get(j).toString());
										
											str7 = boilerprice.get(j).toString();
										    list7 = arr2[i]+",";
										    price7 = arr2[i]+",";
										    et7.setText(df.format(Double.parseDouble(arr2[i])));
											t7 = Integer.parseInt(boilertime.get(j).toString());
											g = Double.parseDouble(arr2[i]);

											
										//===================== Select amount=============================================== 	
									    
										    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(boilerprice.get(j).toString());
										    amount7 = (int) temp;
										    Log.i("amount7 = ",""+amount7);
										  
									
											
											for(int ii = 1 ; ii<=10 ; ii++){
												amountboiler.add(String.valueOf(ii));
												}
											
											    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountboiler);
												empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
												spn7.setAdapter(empolyeeAdapter);
												if(amount7 == 0){
													amount7 = 1;
												}
												spn7.setSelection(amount7-1);
												
												double div = Double.parseDouble(amountboiler.get(amount7-1));
								            	double ans = div * Double.parseDouble(str7);

							 						et7.setText(df.format(ans));
													price7 = ans+",";
													g = ans;
													
													spn7.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
														
											            public void onItemSelected(AdapterView<?> adapterView, 
											          	View view, int i, long ll) { 
											          	// TODO Auto-generated method stub
											            	double div = Double.parseDouble(amountboiler.get(i));
											            	double ans = div * Double.parseDouble(str7);

																et7.setText(df.format(ans));
																price7 = ans+",";
																list7 = textboiler.getText().toString()+",";
																g = ans;
																 
											            	}
											            public void onNothingSelected(AdapterView<?> arg0) {
															// TODO Auto-generated method stub

														} 
									 
										      });
											//==================================================================
											
													textboiler.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long l) { 
										          	// TODO Auto-generated method stub    	
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub
										            	InputMethodManager imm = (InputMethodManager) getSystemService(
										                        INPUT_METHOD_SERVICE);
										                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
													} 
								
									      });
													textboiler.setOnItemClickListener(new  OnItemClickListener(){

													@Override
													public void onItemClick(
															AdapterView<?> arg0,
															View arg1, int i,
															long arg3) {
														// TODO Auto-generated method stub
														spn7.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
															
												            public void onItemSelected(AdapterView<?> adapterView, 
												          	View view, int i, long ll) { 
												          	// TODO Auto-generated method stub
												            	double div = Double.parseDouble(amountboiler.get(i));
												            	double ans = div * Double.parseDouble(str7);
												            		
																	et7.setText(df.format(ans));
																	price7 = ans+",";
																	list7 = textboiler.getText().toString()+",";
																	g = ans;
																	 
												            	}
												            public void onNothingSelected(AdapterView<?> arg0) {
																// TODO Auto-generated method stub

															} 
										
											      });

													}

									            });
									}
									  
									  
									 } 	



								if(arr[i].equals("�Ѵ���к� ")){

									int amount = 0;
									c8.setChecked(true);
							        spn8.setEnabled(true);
							        
							        rs = con.selectData("SELECT * FROM Item WHERE OID = '104201310110005' ");	
									try {

										    rs.next();
										    str8 = rs.getString("LastBuyPrice");
										    list8 = rs.getString("ItemName")+",";
										    price8 = arr2[i]+",";
										    t8 = Integer.parseInt(rs.getString("Duration").toString());
										    et8.setText(df.format(Double.parseDouble(arr2[i])));
										    h = Double.parseDouble(arr2[i]);
										    
										  
										    
										    
										    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(rs.getString("LastBuyPrice"));
										    amount = (int) temp;

										    
									} catch (SQLException e) { 
										// TODO Auto-generated catch block
										e.printStackTrace();
									}  
							 
							        for(int k = 1 ; k<=10 ; k++){
							        	amountgrease.add(String.valueOf(k));
										}
							       
							        ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountgrease);
									empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
									spn8.setAdapter(empolyeeAdapter);
									spn8.setSelection(amount-1);
									
									spn8.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
										
							            public void onItemSelected(AdapterView<?> adapterView, 
							          	View view, int i, long ll) { 
							          	// TODO Auto-generated method stub
							            	double div = Double.parseDouble(amountgrease.get(i));
							            	double ans = div * Double.parseDouble(str8);
		 
												et8.setText(df.format(ans));
												price8 = ans+",";
												h = ans;
												 
							            	}
							            public void onNothingSelected(AdapterView<?> arg0) {
											// TODO Auto-generated method stub

										} 
					
						      });

								}
						
						
						 //==========================check 9 ======================================
				
						for(int j = 0 ; j<brakename.size() ; j++){
							
							  if(arr[i].equals(brakename.get(j))){
								
							
								   c9.setChecked(true);
								   textbrake.setEnabled(true);
						           spn9.setEnabled(true);
								
						 
								
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, brakename);
								textbrake.setThreshold(1);
								textbrake.setAdapter(adapter);
								textbrake.setText(brakename.get(j).toString());
								
									str9 = brakeprice.get(j).toString();
								    list9 = arr2[i]+",";
								    price9 = arr2[i]+",";
								    et9.setText(df.format(Double.parseDouble(arr2[i])));
									t9 = Integer.parseInt(braketime.get(j).toString());
									ii = Double.parseDouble(arr2[i]);

									
								//===================== Select amount=============================================== 	
							    
								    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(brakeprice.get(j).toString());
								    amount9 = (int) temp;
								    Log.i("amount9 = ",""+amount9);
								  
							
									
									for(int ii = 1 ; ii<=10 ; ii++){
										amountbrake.add(String.valueOf(ii));
										}
									
									    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountbrake);
										empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
										spn9.setAdapter(empolyeeAdapter);
										if(amount9 == 0){
											amount9 = 1;
										}
										spn9.setSelection(amount9-1);
										
										double div = Double.parseDouble(amountbrake.get(amount9-1));
						            	double ans = div * Double.parseDouble(str9);

					 						et9.setText(df.format(ans));
											price9 = ans+",";
											ii = ans;
											
											spn9.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long ll) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountbrake.get(i));
									            	double ans = div * Double.parseDouble(str9);

														et9.setText(df.format(ans));
														price9 = ans+",";
														list9 = textbrake.getText().toString()+",";
														ii = ans;
														 
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							 
								      });
									//==================================================================
									
											textbrake.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long l) { 
								          	// TODO Auto-generated method stub    	
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub
								            	InputMethodManager imm = (InputMethodManager) getSystemService(
								                        INPUT_METHOD_SERVICE);
								                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
											} 
						
							      });
											textbrake.setOnItemClickListener(new  OnItemClickListener(){

											@Override
											public void onItemClick(
													AdapterView<?> arg0,
													View arg1, int i,
													long arg3) {
												// TODO Auto-generated method stub
												spn9.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long ll) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountbrake.get(i));
										            	double ans = div * Double.parseDouble(str9);
										            		
															et9.setText(df.format(ans));
															price9 = ans+",";
															list9 = textbrake.getText().toString()+",";
															ii = ans;
															 
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });

											}

							            });
							}
							  
							  
							 } 	

					
					
						
					 
						
 						 //==========================check 10 ======================================
						
						for(int j = 0 ; j<filtername.size() ; j++){
							
							  if(arr[i].equals(filtername.get(j))){
								
							
								   c10.setChecked(true);
								   textfilter.setEnabled(true);
						           spn10.setEnabled(true);
								
						 
								
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, filtername);
								textfilter.setThreshold(1);
								textfilter.setAdapter(adapter);
								textfilter.setText(filtername.get(j).toString());
								
									str10 = filterprice.get(j).toString();
								    list10 = arr2[i]+",";
								    price10 = arr2[i]+",";
								    et10.setText(df.format(Double.parseDouble(arr2[i])));
									t10 = Integer.parseInt(filtertime.get(j).toString());
									jj = Double.parseDouble(arr2[i]);

									
								//===================== Select amount=============================================== 	
							    
								    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(filterprice.get(j).toString());
								    amount10 = (int) temp;
								    Log.i("amount10 = ",""+amount10);
								  
							
									
									for(int ii = 1 ; ii<=10 ; ii++){
										amountfilter.add(String.valueOf(ii));
										}
									
									    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountfilter);
										empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
										spn10.setAdapter(empolyeeAdapter);
										if(amount10 == 0){
											amount10 = 1;
										}
										spn10.setSelection(amount10-1);
										
										double div = Double.parseDouble(amountfilter.get(amount10-1));
						            	double ans = div * Double.parseDouble(str10);

					 						et10.setText(df.format(ans));
											price10 = ans+",";
											jj = ans;
											
											spn10.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long ll) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountfilter.get(i));
									            	double ans = div * Double.parseDouble(str10);

														et10.setText(df.format(ans));
														price10 = ans+",";
														list10 = textfilter.getText().toString()+",";
														jj = ans;
														 
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							 
								      });
									//==================================================================
									
											textfilter.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long l) { 
								          	// TODO Auto-generated method stub    	
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub
								            	InputMethodManager imm = (InputMethodManager) getSystemService(
								                        INPUT_METHOD_SERVICE);
								                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
											} 
						
							      });
											textfilter.setOnItemClickListener(new  OnItemClickListener(){

											@Override
											public void onItemClick(
													AdapterView<?> arg0,
													View arg1, int i,
													long arg3) {
												// TODO Auto-generated method stub
												spn10.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long ll) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountfilter.get(i));
										            	double ans = div * Double.parseDouble(str10);
										            		
															et10.setText(df.format(ans));
															price10 = ans+",";
															list10 = textbrake.getText().toString()+",";
															jj = ans;
															 
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });

											}

							            });
							}
							  
							  
							 } 	
 
/*						for(int j = 0 ; j<filtername.size() ; j++){
							
							  if(arr[i].equals(filtername.get(j))){
								
							
							    c10.setChecked(true);
								textfilter.setEnabled(true);
						        spn10.setEnabled(true);
								
						 
								
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, filtername);
								textfilter.setThreshold(1);
								textfilter.setAdapter(adapter);
								textfilter.setText(filtername.get(j).toString());
								
								    str10 = filterprice.get(j).toString();
								    list10 = filtername.get(j).toString()+",";
								    price10 = arr2[i]+",";
								    et10.setText(df.format(Double.parseDouble(arr2[i])));
									t10 = Integer.parseInt(time.get(j).toString());
									jj = Double.parseDouble(arr2[i]);
									
								//===================== Select amount=============================================== 	
							    
								    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(str10);
								    amount10 = (int) temp;
								    Log.i("amount10 = ",""+amount10);
							
									
									for(int ii = 1 ; ii<=10 ; ii++){
										amountfilter.add(String.valueOf(ii));
										}
									
									    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountfilter);
										empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
										spn10.setAdapter(empolyeeAdapter);
										if(amount10 == 0){
											amount10 = 1;
										}
										spn10.setSelection(amount10-1);
										
										double div = Double.parseDouble(amountfilter.get(amount10-1));
						            	double ans = div * Double.parseDouble(str10);

					 						et10.setText(df.format(ans));
											price10 = ans+",";
											jj = ans;
											
											spn10.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long ll) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountfilter.get(i));
									            	double ans = div * Double.parseDouble(str10);

														et10.setText(df.format(ans));
														price10 = ans+",";
														list10 = textfilter.getText().toString()+",";
														jj = ans;
														 
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
									//==================================================================
									
										   textfilter.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long l) { 
								          	// TODO Auto-generated method stub    	
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub
								            	InputMethodManager imm = (InputMethodManager) getSystemService(
								                        INPUT_METHOD_SERVICE);
								                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
											} 
						
							      });
							            textfilter.setOnItemClickListener(new  OnItemClickListener(){

											@Override
											public void onItemClick(
													AdapterView<?> arg0,
													View arg1, int i,
													long arg3) {
												// TODO Auto-generated method stub
												spn10.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long ll) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountfilter.get(i));
										            	double ans = div * Double.parseDouble(str10);

															et10.setText(df.format(ans));
															price10 = ans+",";
															jj = ans;
															list10 = textfilter.getText().toString()+",";
															 
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });
		
											}
		
							            });

							}
							 } 
*/	 
						 //==========================check 11 ======================================
						
						for(int j = 0 ; j<filterAirname.size() ; j++){
							
							  if(arr[i].equals(filterAirname.get(j))){
								
							
								   c11.setChecked(true);
								   textfilterAir.setEnabled(true);
						           spn11.setEnabled(true);
								
						           
								
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, filterAirname);
								textfilterAir.setThreshold(1);
								textfilterAir.setAdapter(adapter);
								textfilterAir.setText(filterAirname.get(j).toString());
								
									str11 = filterAirprice.get(j).toString();
								    list11 = arr2[i]+",";
								    price11 = arr2[i]+",";
								    et11.setText(df.format(Double.parseDouble(arr2[i])));
									t11 = Integer.parseInt(filterAirtime.get(j).toString());
									k = Double.parseDouble(arr2[i]);

									
								//===================== Select amount=============================================== 	
							    
								    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(filterAirprice.get(j).toString());
								    amount11 = (int) temp;
								    Log.i("amount11 = ",""+amount11);
								  
							
									
									for(int ii = 1 ; ii<=10 ; ii++){
										amountfilterAir.add(String.valueOf(ii));
										}
									
									    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountfilterAir);
										empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
										spn11.setAdapter(empolyeeAdapter);
										if(amount11 == 0){
											amount11 = 1;
										}
										spn11.setSelection(amount11-1);
										
										double div = Double.parseDouble(amountfilterAir.get(amount11-1));
						            	double ans = div * Double.parseDouble(str11);

					 						et11.setText(df.format(ans));
											price11 = ans+",";
											k = ans;
											
											spn11.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long ll) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountfilterAir.get(i));
									            	double ans = div * Double.parseDouble(str11);

														et11.setText(df.format(ans));
														price11 = ans+",";
														list11 = textfilterAir.getText().toString()+",";
														k = ans;
														 
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							 
								      });
									//==================================================================
									
											textfilterAir.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long l) { 
								          	// TODO Auto-generated method stub    	
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub
								            	InputMethodManager imm = (InputMethodManager) getSystemService(
								                        INPUT_METHOD_SERVICE);
								                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
											} 
						
							      });
											textfilterAir.setOnItemClickListener(new  OnItemClickListener(){

											@Override
											public void onItemClick(
													AdapterView<?> arg0,
													View arg1, int i,
													long arg3) {
												// TODO Auto-generated method stub
												spn11.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long ll) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountfilterAir.get(i));
										            	double ans = div * Double.parseDouble(str11);
										            		
															et11.setText(df.format(ans));
															price11 = ans+",";
															list11 = textbrake.getText().toString()+",";
															k = ans;
															 
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });

											}

							            });
							}
							  
							  
							 } 
							

							

					 

		                   //==========================check 12 ======================================
						 
						
								for(int j = 0 ; j<liquorname.size() ; j++){
									
									  if(arr[i].equals(liquorname.get(j))){
										
									
										   c12.setChecked(true);
										   textliquor.setEnabled(true);
								           spn12.setEnabled(true);
										
								 
										
										ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, liquorname);
										textliquor.setThreshold(1);
										textliquor.setAdapter(adapter);
										textliquor.setText(liquorname.get(j).toString());
										
											str12 = liquorprice.get(j).toString();
										    list12 = arr2[i]+",";
										    price12 = arr2[i]+",";
										    et12.setText(df.format(Double.parseDouble(arr2[i])));
											t12 = Integer.parseInt(liquortime.get(j).toString());
											l = Double.parseDouble(arr2[i]);

											
										//===================== Select amount=============================================== 	
									    
										    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(liquorprice.get(j).toString());
										    amount12 = (int) temp;
										    Log.i("amount12 = ",""+amount12);
										  
									
											
											for(int ii = 1 ; ii<=11 ; ii++){
												amountliquor.add(String.valueOf(ii));
												}
											
											    ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountliquor);
												empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
												spn12.setAdapter(empolyeeAdapter);
												if(amount12 == 0){
													amount12 = 1;
												}
												spn12.setSelection(amount12-1);
												
												double div = Double.parseDouble(amountliquor.get(amount12-1));
								            	double ans = div * Double.parseDouble(str12);

							 						et12.setText(df.format(ans));
													price12 = ans+",";
													l = ans;
													
													spn12.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
														
											            public void onItemSelected(AdapterView<?> adapterView, 
											          	View view, int i, long ll) { 
											          	// TODO Auto-generated method stub
											            	double div = Double.parseDouble(amountliquor.get(i));
											            	double ans = div * Double.parseDouble(str12);

																et12.setText(df.format(ans));
																price12 = ans+",";
																list12 = textliquor.getText().toString()+",";
																l = ans;
																 
											            	}
											            public void onNothingSelected(AdapterView<?> arg0) {
															// TODO Auto-generated method stub

														} 
									 
										      });
											//==================================================================
											
													textliquor.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long l) { 
										          	// TODO Auto-generated method stub    	
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub
										            	InputMethodManager imm = (InputMethodManager) getSystemService(
										                        INPUT_METHOD_SERVICE);
										                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
													} 
								
									      });
													textliquor.setOnItemClickListener(new  OnItemClickListener(){

													@Override
													public void onItemClick(
															AdapterView<?> arg0,
															View arg1, int i,
															long arg3) {
														// TODO Auto-generated method stub
														spn12.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
															
												            public void onItemSelected(AdapterView<?> adapterView, 
												          	View view, int i, long ll) { 
												          	// TODO Auto-generated method stub
												            	double div = Double.parseDouble(amountliquor.get(i));
												            	double ans = div * Double.parseDouble(str12);
												            		
																	et12.setText(df.format(ans));
																	price12 = ans+",";
																	list12 = textliquor.getText().toString()+",";
																	l = ans;
																	 
												            	}
												            public void onNothingSelected(AdapterView<?> arg0) {
																// TODO Auto-generated method stub

															} 
										
											      });

													}

									            });
									}
									  
									  
									 } 	

						
						
						
								
						if(arr[i].equals("��ҧ�Ѵ�մ")){

							int amount = 0;
							c13.setChecked(true);
					        spn13.setEnabled(true);
					        
					        rs = con.selectData("SELECT * FROM Item WHERE OID = '104201310100002' ");	
							try {

								    rs.next();
								    str13 = rs.getString("LastBuyPrice");
								    list13 = rs.getString("ItemName")+",";
								    price13 = arr2[i]+",";
								    t13 = Integer.parseInt(rs.getString("Duration").toString());
								    et13.setText(df.format(Double.parseDouble(arr2[i])));
								    m = Double.parseDouble(arr2[i]);
								    
								    
								    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(rs.getString("LastBuyPrice"));
								    amount = (int) temp;
								   
								    
							} catch (SQLException e) { 
								// TODO Auto-generated catch block
								e.printStackTrace();
							}  
					        
					      for(int k = 1 ; k<=10 ; k++){
					        	amountcompress.add(String.valueOf(k));
								}
					        
					        ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountcompress);
							empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
							spn13.setAdapter(empolyeeAdapter);
							    	spn13.setSelection(amount-1);
							    	
							    	spn13.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
										
							            public void onItemSelected(AdapterView<?> adapterView, 
							          	View view, int i, long l) { 
							          	// TODO Auto-generated method stub
							            	double div = Double.parseDouble(amountcompress.get(i));
							            	double ans = div * Double.parseDouble(str13);

												et13.setText(df.format(ans));
												price13 = ans+",";
												m = ans;
												 
							            	}
							            public void onNothingSelected(AdapterView<?> arg0) {
											// TODO Auto-generated method stub

										} 
					
						      });
                           
						}
								
						
						if(arr[i].equals("��ҧ��")){

							
							c14.setChecked(true);
					        spn14.setEnabled(true);
					        
					        rs = con.selectData("SELECT * FROM Item WHERE OID = '104201310110007' ");	
							try {

								    rs.next();
								    str14 = rs.getString("LastBuyPrice");
								    list14 = rs.getString("ItemName")+",";
								    price14 = arr2[i]+",";
								    t14 = Integer.parseInt(rs.getString("Duration").toString());
								    et14.setText(df.format(Double.parseDouble(arr2[i])));
								    n = Double.parseDouble(arr2[i]);
								    Log.i("str14",str14);
								    Log.i("n1",""+n);
								
								    double temp = Double.parseDouble(arr2[i])/Double.parseDouble(rs.getString("LastBuyPrice"));
								    amount14 = (int) temp;
		
								    
							} catch (SQLException e) { 
								// TODO Auto-generated catch block
								e.printStackTrace();
							}  
					        
					        for(int k = 1 ; k<=10 ; k++){
					        	amountcolor.add(String.valueOf(k));
								}
					        
					        ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountcolor);
							empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
							spn14.setAdapter(empolyeeAdapter);
							spn14.setSelection(amount14-1);
							
							
							spn14.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
								
					            public void onItemSelected(AdapterView<?> adapterView, 
					          	View view, int i, long l) { 
					          	// TODO Auto-generated method stub
					            	double div = Double.parseDouble(amountcolor.get(i));
					            	double ans = div * Double.parseDouble(str14);

										et14.setText(df.format(ans));
										price14 = ans+",";
										n = ans;
										  Toast.makeText(HoleActivity_edit.this, "div = "+div, Toast.LENGTH_SHORT).show();
										  Toast.makeText(HoleActivity_edit.this, "n = "+n, Toast.LENGTH_SHORT).show();
					            	}
					            public void onNothingSelected(AdapterView<?> arg0) {
									// TODO Auto-generated method stub

								} 
			
				      });
						
							
		
                              
						} 
						
				
					}
					
					if(!check.equals("")){
						
						c15.setChecked(true);
						orther1.setEnabled(true);
						et15.setEnabled(true);
						
						String a = "";
						String b = "";
						String c = "";
						
						if(arr[(arr.length-3)].equals("-")) {
							a = "";
						}else{
							a = arr[(arr.length-3)];
						}
						
						if(arr[(arr.length-2)].equals("-")) {
							b = "";
						}else{
							b = ","+arr[(arr.length-2)];
						}
						
						if(arr[(arr.length-1)].equals("-")) {
							c = "";
						}else{
							c = ","+arr[(arr.length-1)];
						}
						orther1.setText(a+b+c);
						
						
						double aa = 0;
						double bb = 0;
						double cc = 0;
					
						if(arr2[(arr2.length-3)].equals("-")) {
							aa = 0;
						}else{
							aa = Double.parseDouble(arr2[(arr.length-3)]);
						}
								
						if(arr2[(arr2.length-2)].equals("-")) {
							bb = 0;
						}else{
							bb = Double.parseDouble(arr2[(arr2.length-2)]);
						}
						
						if(arr2[(arr2.length-1)].equals("-")) {
							cc = 0;
						}else{
							cc = Double.parseDouble(arr2[(arr2.length-1)]);
						}
						double p = aa+bb+cc; 
						et15.setText(df.format(p));
						
					
					
					}

			
		
		
		
		
		Sum.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				if(et15.getText().toString().equals("")){
					p = 0;
				}else{
				p = Double.parseDouble(et15.getText().toString());
				}
				
				
				//////////////  ��ǹŴ�ٻͧ	
				sumDiscNull = disc.getText().toString();
				
				if(sumDiscNull.equals(null)||sumDiscNull.equals("")){
					sumDisc = "0";
				}else{
					sumDisc = sumDiscNull;
				}
				sumDisBTHNull = disBTH.getText().toString();
				
				if(sumDisBTHNull.equals(null)||sumDisBTHNull.equals("")){
					sumDisBTH = "0";
				}else{
					
					sumDisBTH = sumDisBTHNull;
				}
			////////////////���ǹŴ VIP
				VIPcode = prom.getText().toString();
				
				
				
				
				timeSum = t1+t2+t3+t4+t5+t6+t7+t8+t9+t10+t11+t12+t13+t14;
				timeSum = timeSum+0;
				Toast.makeText(HoleActivity_edit.this, "All time is : "+timeSum, Toast.LENGTH_SHORT).show();
				
				amount = a+b+c+d+e+f+g+h+ii+jj+k+l+m+n+o+p;
				SumAmount.setText(String.valueOf(df.format(amount)));
				
				finalSum = (amount-Integer.parseInt(sumDisBTH))-(((amount-Integer.parseInt(sumDisBTH))*Integer.parseInt(sumDisc))/100);
				

				TextSum.setText(String.valueOf(df.format(finalSum)));	
				//TextSum.setText(String.valueOf(finalSum));	
				
				

			}
			});   
		 
		
		final Calendar c = Calendar.getInstance();
		    
        mYear = c.get(Calendar.YEAR);
        mMonth = c.get(Calendar.MONTH);
        mDay = c.get(Calendar.DAY_OF_MONTH); 
		 
		 btn1.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					
					if(services_edit.CHECH_ADD){	
					
					if(orther1.getText().toString().equals("")){
       					price15 = "-,";
    	   				list15 = "-,";
    	   				
    	   				price16 = "-,";
    	   				list16 = "-,";
    	   				
    	   				price17 = "-,";
    	   				list17 = "-,";
    				}else{
    					String [] count = orther1.getText().toString().split(",");
    					
    					Log.i("count = ",""+count.length);


    					
    					if(count.length == 3){
    					price15 = et15.getText().toString()+",";
    	   				list15 = orther1.getText().toString()+",";
    	   				
    	   				price16 = "-,";
    	   				
    	   				price17 = "-,";
    	   				
    					}else if (count.length == 2){
    						price15 = et15.getText().toString()+",";
	    	   				list15 = orther1.getText().toString()+",";
	    	   				
	    	   				list16 = "-,";
	    	   				price16 = "-,";
	    	   				
	    	   				price17 = "-,";
	    	   				
	    	   				
	    	   				
    					}else if (count.length == 1){
    						price15 = et15.getText().toString()+",";
	    	   				list15 = orther1.getText().toString()+",";
	    	   				
	    	   				price16 = "-,";
	    	   				list16 = "-,";
	    	   				
	    	   				price17 = "-,";
	    	   				list17 = "-,";
    					}
    				}
    				 
    				 
    	 			
					
				
					 
				    String sql = "UPDATE DataService " +
							"SET List = '"+list1+list2+list3+list4+list5+list6+list7+list8+list9+
							               list10+list11+list12+list13+list14+list15+list16+list17+"', " +
				    		     "price = '"+price1+price2+price3+price4+price5+price6+price7+price8+price9+
									price10+price11+price12+price13+price14+price15+price16+price17+"', " +
									"VIPcode = '"+VIPcode+"', "+
					    		     "Discount = '"+sumDisc+"', " +
					    		     "amount = '"+amount+"', " +
					    		     "Sum = '"+finalSum+"', " +
					    		     "sumTime = '"+timeSum+"', " +
					    		     "date = '"+mDay+"/"+(1+mMonth)+"/"+mYear+"', " +
					    		     "DiscountName = '"+DisCt+"', " +
                                      "PriceBTH = '"+sumDisBTH+"' "+
					    		     
								    		    
								    		     
								"WHERE id = '"+idDataService+"' ";
								    
				    Toast.makeText(HoleActivity_edit.this, "checkOrther1 = "+checkOrther1, Toast.LENGTH_SHORT).show();
   				
					
					if(con.editData(sql)){	 
						Toast.makeText(HoleActivity_edit.this, "Update data successfully", Toast.LENGTH_SHORT).show();
						Toast.makeText(HoleActivity_edit.this,  ServiceIDEDT , Toast.LENGTH_SHORT).show();
						//Open Form Add
						Toast.makeText(HoleActivity_edit.this, ServiceIDEDT, Toast.LENGTH_SHORT).show();
						Intent newActivityAdd = new Intent(HoleActivity_edit.this,Card_Edit.class);
						newActivityAdd.putExtra("name", NameInput);
						newActivityAdd.putExtra("CompanyS", company);
						newActivityAdd.putExtra("ServiceID", ServiceIDEDT);
						startActivity(newActivityAdd);
						
						}else{
					    Toast.makeText(HoleActivity_edit.this, "Update data fail", Toast.LENGTH_SHORT).show();
					   
					    
						}
						
					

						}else{
							
							services_edit.CHECH_ADD = true;
							  Toast.makeText(HoleActivity_edit.this, "���������", Toast.LENGTH_SHORT).show();
							  Intent i = new Intent();
								i.putExtra("time", timeSum+"");
								i.putExtra("Money", finalSum+"");
								i.putExtra("list", list1+list2+list3+list4+list5+list6+list7+list8+list9+
										list10+list11+list12+list13+list14);
								i.putExtra("price", price1+price2+price3+price4+price5+price6+price7+price8+price9+
										price10+price11+price12+price13+price14);
								i.putExtra("name", NameInput);
								i.putExtra("CompanyS", company);
								setResult(services_edit.REQUEST_CODE, i);
							    finish();
							
						}
						
				}
						});

		 
		 
		 
/////////////////////////////////////// edit Hole /////////////////////////////
							
				
					}
					
	
	
	private void orther1() {

		  
		 
		 c15.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
	    			if(c15.isChecked()){
	    				checkOrther1 = "checkOrther";
	    				orther1.setEnabled(true);
	    				et15.setEnabled(true);	
							
							
							
			
				
	    				}
	    			else {
	    				checkOrther1 = "";
	    				p = 0;
	    				orther1.setText("");
	    				et15.setText("");
	    				orther1.setEnabled(false);
	    				et15.setEnabled(false);
	    				}
	            }
	        });
}
	
	

	
	
private void motorOil() {

		
		 c1.setOnClickListener(new View.OnClickListener() {
			
				@Override
				public void onClick(View v) {
	    			if(c1.isChecked()){
	    				
	    				name.clear();
	    				price.clear();
	    				time.clear();
	    				
	    				spn1.setEnabled(true);
	    				textmotorOil.setEnabled(true);
	    				
	    				
	    				 rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201309160001' ");
						 try {
								while(rs.next()){          
								
									name.add(rs.getString("ItemName"));	
									price.add(rs.getString("LastBuyPrice"));	
									time.add(rs.getString("Duration"));	
									
									}
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
						
									amountOne.clear();
									for(int i = 1 ; i<=10 ; i++){
										amountOne.add(String.valueOf(i));
										}
									
									
									
									ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, name);
									textmotorOil.setThreshold(1);
							         
									textmotorOil.setAdapter(adapter);
							        
									textmotorOil.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
										
							            public void onItemSelected(AdapterView<?> adapterView, 
							          	View view, int i, long l) { 
							          	// TODO Auto-generated method stub    	
							            	}
							            public void onNothingSelected(AdapterView<?> arg0) {
											// TODO Auto-generated method stub
							            	InputMethodManager imm = (InputMethodManager) getSystemService(
							                        INPUT_METHOD_SERVICE);
							                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
										} 
					
						      });

									textmotorOil.setOnItemClickListener(new  OnItemClickListener(){
											@Override
											public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
												// TODO Auto-generated method stub
												
												
								            	
								            	String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201309160001' and ItemName = '"+arg0.getItemAtPosition(position).toString()+"'  ";
								            	ResultSet rs = con.selectData(sql);
								            	try {
													while(rs.next()){   
														//et1.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
										            	list1 = rs.getString("ItemName")+",";
										                //price1 = rs.getString("LastBuyPrice")+",";
										            	t1 = Integer.parseInt(rs.getString("Duration"));
										            	str1 = rs.getString("LastBuyPrice");
														}
												} catch (SQLException e) {
													// TODO Auto-generated catch block
													e.printStackTrace();
												}   
								            	
								            	 
								            	
								            	 Toast.makeText(HoleActivity_edit.this,"list1 = "+list1, Toast.LENGTH_SHORT).show();
												 
								            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(position).toString(), Toast.LENGTH_SHORT).show();
												 Log.i("AutocompleteContacts", "Position:"+position+" Month:"+arg0.getItemAtPosition(position));
												 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountOne);
													empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
													spn1.setAdapter(empolyeeAdapter);
													
													spn1.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
														
											            public void onItemSelected(AdapterView<?> adapterView, 
											          	View view, int i, long l) { 
											          	// TODO Auto-generated method stub
											            	double div = Double.parseDouble(amountOne.get(i));
											            	double ans = div * Double.parseDouble(str1);
											            	
											            	et1.setText(df.format(ans));
											                price1 = String.valueOf(ans)+",";
											            	a = ans;
											            	
											            	}
											            public void onNothingSelected(AdapterView<?> arg0) {
															// TODO Auto-generated method stub

														} 
									
										      });
											}

							            });
									
									
				}
	    			else {
	    				 a = 0;
	    				 t1 = 0;
	    				 price.clear();
					     name.clear();
					     textmotorOil.setEnabled(false);
					     textmotorOil.setText("");
	    				 et1.setText("");
	    				 list1 = "";
	    				 price1 = "";
	    				 spn1.setEnabled(false);
	    				}
	            }
	        });	
				
				
			
		}	

private void GearOil() {
	
		c2.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
    			if(c2.isChecked()){
    				
    				
    				Gearprice.clear();
    				Gearname.clear();
    				Geartime.clear();
    				
    				
    				 spn2.setEnabled(true);
    				textGearOil.setEnabled(true);
    				
    				 rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201309160002' ");		   

						try {
							while(rs.next()){          
								Gearprice.add(rs.getString("LastBuyPrice"));	
								Gearname.add(rs.getString("ItemName"));	
								Geartime.add(rs.getString("Duration"));
								}
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
					 
								for(int i = 1 ; i<=10 ; i++){
									amountGear.add(String.valueOf(i));
									}
								
								
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, Gearname);
								textGearOil.setThreshold(1);
						         
								textGearOil.setAdapter(adapter);
								
						        
								textGearOil.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
									
						            public void onItemSelected(AdapterView<?> adapterView, 
						          	View view, int i, long l) { 
						          	// TODO Auto-generated method stub    	
						            	}
						            public void onNothingSelected(AdapterView<?> arg0) {
										// TODO Auto-generated method stub
						            	InputMethodManager imm = (InputMethodManager) getSystemService(
						                        INPUT_METHOD_SERVICE);
						                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
									} 
				
					      });

								textGearOil.setOnItemClickListener(new  OnItemClickListener(){
										@Override
										public void onItemClick(AdapterView<?> arg0, View arg1, int i, long arg3) {
											// TODO Auto-generated method stub
											
											String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201309160002' and ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
							            	ResultSet rs = con.selectData(sql);
							            	try {
												while(rs.next()){   
													//et2.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
									            	list2 = rs.getString("ItemName")+",";
									            	//price2 = rs.getString("LastBuyPrice")+",";
									            	t2 = Integer.parseInt(rs.getString("Duration"));
									            	str2 = rs.getString("LastBuyPrice");
													}
											} catch (SQLException e) {
												// TODO Auto-generated catch block
												e.printStackTrace();
											}    	
							            	 Toast.makeText(HoleActivity_edit.this,"list2 = "+list2, Toast.LENGTH_SHORT).show();
											 
							            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
											 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i));
											
											 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountGear);
												empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
												spn2.setAdapter(empolyeeAdapter);
												
												spn2.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long l) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountGear.get(i));
										            	double ans = div * Double.parseDouble(str2);
										            	
										            	et2.setText(df.format(ans));
										                price2 = String.valueOf(ans)+",";
										            	b = ans;
										            	
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });
										
										}

						            });

    			}
    			else {
    				 b = 0;
    				 t2 = 0;
    				 Gearprice.clear();
				     Gearname.clear();
				     textGearOil.setEnabled(false);
				     spn2.setEnabled(false);
				     textGearOil.setText("");
    				 et2.setText("");
    				 list2 = "";
    				 price2 = "";
    				}
            }
        });	
			
			
		
	}	 

private void SprocketsOil() {

	
		c3.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
    			if(c3.isChecked()){
    				

    				Sprocketsprice.clear();
    				Sprocketsname.clear();
    				Sprocketstime.clear();
    				spn3.setEnabled(true);
    				textSprocketsOil.setEnabled(true);
				   
    				 rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110001' ");		   
						try {
							while(rs.next()){          
								Sprocketsprice.add(rs.getString("LastBuyPrice"));	
								Sprocketsname.add(rs.getString("ItemName"));	
								Sprocketstime.add(rs.getString("Duration"));
								}
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
						
								for(int i = 1 ; i<=10 ; i++){
									amountSprockets.add(String.valueOf(i));
									}
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, Sprocketsname);
								textSprocketsOil.setThreshold(1);
						         
								textSprocketsOil.setAdapter(adapter); 
						        
								textSprocketsOil.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
									
						            public void onItemSelected(AdapterView<?> adapterView, 
						          	View view, int i, long l) { 
						          	// TODO Auto-generated method stub    	
						            	}
						            public void onNothingSelected(AdapterView<?> arg0) {
										// TODO Auto-generated method stub
						            	InputMethodManager imm = (InputMethodManager) getSystemService(
						                        INPUT_METHOD_SERVICE);
						                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
									} 
				
					      });

								textSprocketsOil.setOnItemClickListener(new  OnItemClickListener(){
										@Override
										public void onItemClick(AdapterView<?> arg0, View arg1, int i, long arg3) {
											// TODO Auto-generated method stub
											
											String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201310110001' and ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
							            	ResultSet rs = con.selectData(sql);
							            	try {
												while(rs.next()){   
													//et3.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
									            	list3 = rs.getString("ItemName")+",";
									            	//price3 = rs.getString("LastBuyPrice")+",";
									            	t3 = Integer.parseInt(rs.getString("Duration"));
									            	str3 = rs.getString("LastBuyPrice");
													}
											} catch (SQLException e) {
												// TODO Auto-generated catch block
												e.printStackTrace();
											}    	
											 
							            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
											 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i));
											
											 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountSprockets);
												empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
												spn3.setAdapter(empolyeeAdapter);
												
												spn3.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long l) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountSprockets.get(i));
										            	double ans = div * Double.parseDouble(str3);
										            	
										            	et3.setText(df.format(ans));
										                price3 = String.valueOf(ans)+",";
										            	c = ans;
										            	
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });
										
										}

						            });

    			}
    			else {
    				c = 0;
    				t3 = 0;
    				Sprocketsprice.clear();
					 Sprocketsname.clear();
					 textSprocketsOil.setEnabled(false);
					 spn3.setEnabled(false);
					 textSprocketsOil.setText("");
    				et3.setText("");
    				list3 = "";
    				price3 = "";
    				}
            }
        });	
			
			
		
	}	

private void GearOilAuto() {

	
	c4.setOnClickListener(new View.OnClickListener() {
	
		@Override
		public void onClick(View v) {
			if(c4.isChecked()){
				
				Sprocketsprice.clear();
				Sprocketsname.clear();
				Sprocketstime.clear();
				
				spn4.setEnabled(true);
				textGearOilAuto.setEnabled(true);	
				
				rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110013' ");		   
				try {
					while(rs.next()){          
						Sprocketsprice.add(rs.getString("LastBuyPrice"));	
						Sprocketsname.add(rs.getString("ItemName"));	
						Sprocketstime.add(rs.getString("Duration"));
						}
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				

							
							for(int i = 1 ; i<=10 ; i++){
								amountGearOilAuto.add(String.valueOf(i));
								}
							ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, GearOilAutoname);
							textGearOilAuto.setThreshold(1);
					         
							textGearOilAuto.setAdapter(adapter);
					        
							textGearOilAuto.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
								
					            public void onItemSelected(AdapterView<?> adapterView, 
					          	View view, int i, long l) { 
					          	// TODO Auto-generated method stub    	
					            	}
					            public void onNothingSelected(AdapterView<?> arg0) {
									// TODO Auto-generated method stub
					            	InputMethodManager imm = (InputMethodManager) getSystemService(
					                        INPUT_METHOD_SERVICE);
					                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
								} 
			
				      });

							textGearOilAuto.setOnItemClickListener(new  OnItemClickListener(){
									@Override
									public void onItemClick(AdapterView<?> arg0, View arg1, int i, long arg3) {
										// TODO Auto-generated method stub
										
										String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201310110012' and ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
						            	ResultSet rs = con.selectData(sql);
						            	try {
											while(rs.next()){   
												//et3.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
								            	list4 = rs.getString("ItemName")+",";
								            	//price3 = rs.getString("LastBuyPrice")+",";
								            	t4 = Integer.parseInt(rs.getString("Duration"));
								            	str4 = rs.getString("LastBuyPrice");
												}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
										}    	
										 
						            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
										 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i));
										
										 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountGearOilAuto);
											empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
											spn4.setAdapter(empolyeeAdapter);
											
											spn4.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long l) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountGearOilAuto.get(i));
									            	double ans = div * Double.parseDouble(str4);
									            	
									            	et4.setText(df.format(ans));
									                price4 = String.valueOf(ans)+",";
									            	d = ans;
									            	
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
									
									}

					            });

			}
			else {
				d = 0;
				t4 = 0;
				GearOilAutoprice.clear();
				GearOilAutoname.clear();
				 textGearOilAuto.setEnabled(false);
				 spn4.setEnabled(false);
				 textGearOilAuto.setText("");
				et4.setText("");
				list4 = "";
				price4 = "";
				}
        }
    });	
		
		
	
}	



private void SteeringWheel() {

	
	c5.setOnClickListener(new View.OnClickListener() {
	
		@Override
		public void onClick(View v) {
			if(c5.isChecked()){
				
				SteeringWheelprice.clear();
				SteeringWheelname.clear();
				SteeringWheeltime.clear();
				
				spn5.setEnabled(true);
				textSteeringWheel.setEnabled(true);	
				
				
				rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110013' ");		   
				try {
					while(rs.next()){          
						SteeringWheelprice.add(rs.getString("LastBuyPrice"));	
						SteeringWheelname.add(rs.getString("ItemName"));	
			            SteeringWheeltime.add(rs.getString("Duration"));
						}
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				   

							
							for(int i = 1 ; i<=10 ; i++){
								amountSteeringWheel.add(String.valueOf(i));
								}
							ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, SteeringWheelname);
							textSteeringWheel.setThreshold(1);
					         
							textSteeringWheel.setAdapter(adapter);
					        
							textSteeringWheel.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
								
					            public void onItemSelected(AdapterView<?> adapterView, 
					          	View view, int i, long l) { 
					          	// TODO Auto-generated method stub    	
					            	}
					            public void onNothingSelected(AdapterView<?> arg0) {
									// TODO Auto-generated method stub
					            	InputMethodManager imm = (InputMethodManager) getSystemService(
					                        INPUT_METHOD_SERVICE);
					                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
								} 
			
				      });

							textSteeringWheel.setOnItemClickListener(new  OnItemClickListener(){
									@Override
									public void onItemClick(AdapterView<?> arg0, View arg1, int i, long arg3) {
										// TODO Auto-generated method stub
										
										String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201310110013' and ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
						            	ResultSet rs = con.selectData(sql);
						            	try {
											while(rs.next()){   
												//et3.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
								            	list5 = rs.getString("ItemName")+",";
								            	//price3 = rs.getString("LastBuyPrice")+",";
								            	t5 = Integer.parseInt(rs.getString("Duration"));
								            	str5 = rs.getString("LastBuyPrice");
												}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
										}    	
										 
						            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
										 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i));
										
										 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountSteeringWheel);
											empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
											spn5.setAdapter(empolyeeAdapter);
											
											spn5.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long l) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountSteeringWheel.get(i));
									            	double ans = div * Double.parseDouble(str5);
									            	
									            	et5.setText(df.format(ans));
									                price5 = String.valueOf(ans)+",";
									            	e = ans;
									            	
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
									
									}

					            });

			}
			else {
				e = 0;
				t5 = 0;
				SteeringWheelprice.clear();
				SteeringWheelname.clear();
				 textSteeringWheel.setEnabled(false);
				 spn5.setEnabled(false);
				 textSteeringWheel.setText("");
				et5.setText("");
				list5 = "";
				price5 = "";
				}
        }
    });	
		
		
	
}	


private void within() {

	
	c6.setOnClickListener(new View.OnClickListener() {
	
		@Override
		public void onClick(View v) {
			if(c6.isChecked()){
				
				withinprice.clear();
				withinname.clear();
				withintime.clear();
				
				spn6.setEnabled(true);
				textwithin.setEnabled(true);		   
				   
				rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110014' ");		   
												try {
														while(rs.next()){          
															withinprice.add(rs.getString("LastBuyPrice"));	
															withinname.add(rs.getString("ItemName"));	
															withintime.add(rs.getString("Duration"));
															}
													} catch (SQLException e) {
														// TODO Auto-generated catch block
														e.printStackTrace();
													}

							
							for(int i = 1 ; i<=10 ; i++){
								amountwithin.add(String.valueOf(i));
								}
							ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, withinname);
							textwithin.setThreshold(1);
					         
							textwithin.setAdapter(adapter);
					        
							textwithin.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
								
					            public void onItemSelected(AdapterView<?> adapterView, 
					          	View view, int i, long l) { 
					          	// TODO Auto-generated method stub    	
					            	}
					            public void onNothingSelected(AdapterView<?> arg0) {
									// TODO Auto-generated method stub
					            	InputMethodManager imm = (InputMethodManager) getSystemService(
					                        INPUT_METHOD_SERVICE);
					                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
								} 
			
				      });

							textwithin.setOnItemClickListener(new  OnItemClickListener(){
									@Override
									public void onItemClick(AdapterView<?> arg0, View arg1, int i, long arg3) {
										// TODO Auto-generated method stub
										
										String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201310110014' and ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
						            	ResultSet rs = con.selectData(sql);
						            	try {
											while(rs.next()){   
												//et3.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
								            	list6 = rs.getString("ItemName")+",";
								            	//price3 = rs.getString("LastBuyPrice")+",";
								            	t6 = Integer.parseInt(rs.getString("Duration"));
								            	str6 = rs.getString("LastBuyPrice");
												}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
										}    	
										 
						            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
										 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i));
										
										 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountwithin);
											empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
											spn6.setAdapter(empolyeeAdapter);
											
											spn6.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long l) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountwithin.get(i));
									            	double ans = div * Double.parseDouble(str6);
									            	
									            	et6.setText(df.format(ans));
									                price6 = String.valueOf(ans)+",";
									            	f = ans;
									            	
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
									
									}

					            });

			}
			else {
				f = 0;
				t6 = 0;
				withinprice.clear();
				withinname.clear();
				 textwithin.setEnabled(false);
				 spn6.setEnabled(false);
				 textwithin.setText("");
				et6.setText("");
				list6 = "";
				price6 = "";
				}
        }
    });	
		
		
	
}

	
private void boiler() {

	
	c7.setOnClickListener(new View.OnClickListener() {
	
		@Override
		public void onClick(View v) {
			if(c7.isChecked()){
				
				boilerprice.clear();
				boilername.clear();
				boilertime.clear();
				
				spn7.setEnabled(true);
				textboiler.setEnabled(true);		   
				   
				rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110015' ");		   
				try {
					while(rs.next()){          
						boilerprice.add(rs.getString("LastBuyPrice"));	
						boilername.add(rs.getString("ItemName"));	
						boilertime.add(rs.getString("Duration"));
						}
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}	
							
							for(int i = 1 ; i<=10 ; i++){
								amountboiler.add(String.valueOf(i));
								}
							ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, boilername);
							textboiler.setThreshold(1);
					         
							textboiler.setAdapter(adapter);
					        
							textboiler.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
								
					            public void onItemSelected(AdapterView<?> adapterView, 
					          	View view, int i, long l) { 
					          	// TODO Auto-generated method stub    	
					            	}
					            public void onNothingSelected(AdapterView<?> arg0) {
									// TODO Auto-generated method stub
					            	InputMethodManager imm = (InputMethodManager) getSystemService(
					                        INPUT_METHOD_SERVICE);
					                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
								} 
			
				      });

							textboiler.setOnItemClickListener(new  OnItemClickListener(){
									@Override
									public void onItemClick(AdapterView<?> arg0, View arg1, int i, long arg3) {
										// TODO Auto-generated method stub
										
										String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201310110015' and ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
						            	ResultSet rs = con.selectData(sql);
						            	try {
											while(rs.next()){   
												//et3.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
								            	list7 = rs.getString("ItemName")+",";
								            	//price3 = rs.getString("LastBuyPrice")+",";
								            	t7 = Integer.parseInt(rs.getString("Duration"));
								            	str7 = rs.getString("LastBuyPrice");
												}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
										}    	
										 
						            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
										 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i));
										
										 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountboiler);
											empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
											spn7.setAdapter(empolyeeAdapter);
											
											spn7.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long l) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountboiler.get(i));
									            	double ans = div * Double.parseDouble(str7);
									            	
									            	et7.setText(df.format(ans));
									                price7 = String.valueOf(ans)+",";
									            	g = ans;
									            	
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
									
									}

					            });

			}
			else {
				g = 0;
				t7 = 0;
				boilerprice.clear();
				boilername.clear();
				 textboiler.setEnabled(false);
				 spn7.setEnabled(false);
				 textboiler.setText("");
				et7.setText("");
				list7 = "";
				price7 = "";
				}
        }
    });	
		
		
	
}

	
	
	private void grease() {
		
	
		 	
		 c8 = ( CheckBox ) this.findViewById ( R.id.check8);			
		 et8 = ( TextView ) this.findViewById ( R.id.result8);
		 
		 c8.setOnClickListener(new View.OnClickListener() {
				String str;
				@Override
				public void onClick(View v) {
	    			if(c8.isChecked()){
	    				
	    				
	    				
	    				spn8.setEnabled(true);
			
	    				 rs = con.selectData("SELECT * FROM Item WHERE OID = '104201310110005' ");	
						try {

							    rs.next();
							    str = rs.getString("LastBuyPrice");
							    list8 = rs.getString("ItemName")+",";
							   // price8 = rs.getString("LastBuyPrice")+",";
							    t8 = Integer.parseInt(rs.getString("Duration").toString());
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}  
						for(int i = 1 ; i<=10 ; i++){
							amountgrease.add(String.valueOf(i));
							}
							
							ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountgrease);
							empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
							spn8.setAdapter(empolyeeAdapter);
							
							spn8.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
								
					            public void onItemSelected(AdapterView<?> adapterView, 
					          	View view, int i, long l) { 
					          	// TODO Auto-generated method stub
					            	double div = Double.parseDouble(amountgrease.get(i));
					            	double ans = div * Double.parseDouble(str);

										et8.setText(df.format(ans));
										price8 = String.valueOf(ans)+",";
										h = ans;
					            	}
					            public void onNothingSelected(AdapterView<?> arg0) {
									// TODO Auto-generated method stub

								} 
			
				      });
					   
					
	    				}
	    			else {
	    				t8 = 0;
	    				 h = 0;
	    				 et8.setText("");  
	    				 list8 = "";
	    				 price8 = "";
	    				 spn8.setEnabled(false);
	    				 amountgrease.clear();
	    				}
	            }
	        });


			
		}	
	
	private void brake() {

		
		c9.setOnClickListener(new View.OnClickListener() {
		
			@Override
			public void onClick(View v) {
				if(c9.isChecked()){
					
					brakeprice.clear();
					brakename.clear();
					braketime.clear();
					
					spn9.setEnabled(true);
					textbrake.setEnabled(true);		   
					   
					rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201309160003' ");		   
					
															try {
																while(rs.next()){          
																	brakeprice.add(rs.getString("LastBuyPrice"));	
																	brakename.add(rs.getString("ItemName"));	
																	braketime.add(rs.getString("Duration"));
																	}
															} catch (SQLException e) {
																// TODO Auto-generated catch block
																e.printStackTrace();
															} 
								
								for(int i = 1 ; i<=10 ; i++){
									amountbrake.add(String.valueOf(i));
									}
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, brakename);
								textbrake.setThreshold(1);
						         
								textbrake.setAdapter(adapter);
						        
								textbrake.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
									
						            public void onItemSelected(AdapterView<?> adapterView, 
						          	View view, int i, long l) { 
						          	// TODO Auto-generated method stub    	
						            	}
						            public void onNothingSelected(AdapterView<?> arg0) {
										// TODO Auto-generated method stub
						            	InputMethodManager imm = (InputMethodManager) getSystemService(
						                        INPUT_METHOD_SERVICE);
						                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
									} 
				
					      });

								textbrake.setOnItemClickListener(new  OnItemClickListener(){
										@Override
										public void onItemClick(AdapterView<?> arg0, View arg1, int i, long arg3) {
											// TODO Auto-generated method stub
											
											String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201309160003' and ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
							            	ResultSet rs = con.selectData(sql);
							            	try {
												while(rs.next()){   
													//et3.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
									            	list9 = rs.getString("ItemName")+",";
									            	//price3 = rs.getString("LastBuyPrice")+",";
									            	t9 = Integer.parseInt(rs.getString("Duration"));
									            	str9 = rs.getString("LastBuyPrice");
													}
											} catch (SQLException e) {
												// TODO Auto-generated catch block
												e.printStackTrace();
											}    	
											 
							            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
											 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i));
											
											 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountbrake);
												empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
												spn9.setAdapter(empolyeeAdapter);
												
												spn9.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long l) { 
										          	// TODO Auto-generated method stub
										            	double div = Double.parseDouble(amountbrake.get(i));
										            	double ans = div * Double.parseDouble(str9);
										            	
										            	et9.setText(df.format(ans));
										                price9 = String.valueOf(ans)+",";
										            	ii = ans;
										            	
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });
										
										}

						            });

				}
				else {
					ii = 0;
					t9 = 0;
					brakeprice.clear();
					brakename.clear();
					 textbrake.setEnabled(false);
					 spn9.setEnabled(false);
					 textbrake.setText("");
					et9.setText("");
					list9 = "";
					price9 = "";
					}
	        }
	    });	
			
			
		
	}
/*	
private void filter() {

		
		c10.setOnClickListener(new View.OnClickListener() {
		
			@Override
			public void onClick(View v) {
				if(c10.isChecked()){
					spn10.setEnabled(true);
					textfilter.setEnabled(true);	
					
					rs = con.selectData("SELECT *,ItemCode+' '+ItemName AS ItemCo FROM Item WHERE ItemGroupCode = '105201309160011' ");		   

					try {
						while(rs.next()){          
							filterprice.add(rs.getString("LastBuyPrice"));	
							filtername.add(rs.getString("ItemCo"));	
							filtertime.add(rs.getString("Duration"));
							}
					} catch (SQLException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
					   

								
								for(int i = 1 ; i<=10 ; i++){
									amountfilter.add(String.valueOf(i));
									}
								ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, filtername);
								textfilter.setThreshold(1);
						         
								textfilter.setAdapter(adapter);
						        
								textfilter.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
									
						            public void onItemSelected(AdapterView<?> adapterView, 
						          	View view, int i, long l) { 
						          	// TODO Auto-generated method stub    	
						            	}
						            public void onNothingSelected(AdapterView<?> arg0) {
										// TODO Auto-generated method stub
						            	InputMethodManager imm = (InputMethodManager) getSystemService(
						                        INPUT_METHOD_SERVICE);
						                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
									} 
				
					      });
 
								textfilter.setOnItemClickListener(new  OnItemClickListener(){
										@Override
										public void onItemClick(AdapterView<?> arg0, View arg1, int i, long arg3) {
											// TODO Auto-generated method stub
											
											 Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
											String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201309160011' and ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
							            	  rs = con.selectData(sql);
							            	try {
												rs.next();
													//et3.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
									            	list10 = rs.getString("ItemName")+",";
									            	//price3 = rs.getString("LastBuyPrice")+",";
									            	t10 = Integer.parseInt(rs.getString("Duration"));
									            	str10 = rs.getString("LastBuyPrice");
													
											} catch (SQLException e) {
												// TODO Auto-generated catch block
												e.printStackTrace();
											}    	
											 
							            	 
											 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i)+str10);
											
											   ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountfilter);
												empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
												spn10.setAdapter(empolyeeAdapter);
												
												spn10.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
													
										            public void onItemSelected(AdapterView<?> adapterView, 
										          	View view, int i, long l) { 
										          	// TODO Auto-generated method stub
										            	//double div = 10;
										            //	double div = Double.parseDouble(amountfilter.get(i));
										            //	double ans = div * Double.parseDouble(str10);
										            	Toast.makeText(HoleActivity_edit.this,"str10 = "+str10 , Toast.LENGTH_SHORT).show();
										            	Toast.makeText(HoleActivity_edit.this,"list10 = "+list10 , Toast.LENGTH_SHORT).show();
										            	Toast.makeText(HoleActivity_edit.this,"t10 = "+t10 , Toast.LENGTH_SHORT).show();
										            	double ans = 10.0;
										            	et10.setText(df.format(ans));
										                price10 = String.valueOf(ans)+",";
										            	jj = ans;
										            	
										            	}
										            public void onNothingSelected(AdapterView<?> arg0) {
														// TODO Auto-generated method stub

													} 
								
									      });
										
										}

						            });

				}
				else {
					jj = 0;
					t10 = 0;
					filterprice.clear();
					filtername.clear();
					 textfilter.setEnabled(false);
					 spn10.setEnabled(false);
					 textfilter.setText("");
					et10.setText("");
					list10 = "";
					price10 = "";
					}
	        }
	    });	
			
			
		
	}
	*/
	
	
	private void filter() {
			
			c10.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
	    			if(c10.isChecked()){
	    				filterprice.clear();
	    				filtername.clear();
	    				 spn10.setEnabled(true);
	    				textfilter.setEnabled(true);
						 rs = con.selectData("SELECT *,ItemCode+' '+ItemName AS ItemCo FROM Item WHERE ItemGroupCode = '105201309160011' ");		   

									try {
										while(rs.next()){          
											filterprice.add(rs.getString("LastBuyPrice"));	
											filtername.add(rs.getString("ItemCo"));	
											filtertime.add(rs.getString("Duration"));
		
											}
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}   
									
									for(int i = 1 ; i<=10 ; i++){
										amountfilter.add(String.valueOf(i));
										}
									
									ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, filtername);
									textfilter.setThreshold(1);
							         
									textfilter.setAdapter(adapter);
							         
									textfilter.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long l) { 
								          	// TODO Auto-generated method stub    	
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub
								            	InputMethodManager imm = (InputMethodManager) getSystemService(
								                        INPUT_METHOD_SERVICE);
								                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
											} 
						
							      });
									textfilter.setOnItemClickListener(new  OnItemClickListener(){

											@Override
											public void onItemClick(
													AdapterView<?> arg0,
													View arg1, int i,
													long arg3) {
												// TODO Auto-generated method stub
												
												String sql = "SELECT *,ItemCode+' '+ItemName AS ItemCo FROM Item WHERE ItemGroupCode = '105201309160011' and ItemCode+' '+ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
								            	ResultSet rs = con.selectData(sql);
								            	try {
													while(rs.next()){   
														//et10.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
										            	list10 = rs.getString("ItemCo")+",";
										            //	price10 = rs.getString("LastBuyPrice")+",";
										            	t10 = Integer.parseInt(rs.getString("Duration"));
										            	str10 = rs.getString("LastBuyPrice");
														}
												} catch (SQLException e) {
													// TODO Auto-generated catch block
													e.printStackTrace();
												} 
								            	
								            	
								            	 Toast.makeText(HoleActivity_edit.this,"list10 = "+list10, Toast.LENGTH_SHORT).show();
								            	 Toast.makeText(HoleActivity_edit.this,"list10_2 = "+filtername.get(i).toString(), Toast.LENGTH_SHORT).show();
								            	
								            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
												 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i));
												
												 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountfilter);
													empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
													spn10.setAdapter(empolyeeAdapter);
													
													spn10.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
														
											            public void onItemSelected(AdapterView<?> adapterView, 
											          	View view, int i, long l) { 
											          	// TODO Auto-generated method stub
											            	double div = Double.parseDouble(amountfilter.get(i));
											            	double ans = div * Double.parseDouble(str10);
											            	
											            	et10.setText(df.format(ans));
											                price10 = String.valueOf(ans)+",";
											            	jj = ans;
											            	
											            	}
											            public void onNothingSelected(AdapterView<?> arg0) {
															// TODO Auto-generated method stub

														} 
									
										      });
											
											}

										
							            	
							            });
		
	    			}
	    			else {
	    				t10 = 0;
	    				jj = 0;
	    				filterprice.clear();
	    				filtername.clear();
	    				textfilter.setEnabled(false);
	    				textfilter.setText("");
	    				et10.setText("");
	    				 list10 = "";
	    				 price10 = "";
	    				}
	            }
	        });	
				
				
			
		}	 
	
	
/*	
	
private void filterAir() {

	
	c11.setOnClickListener(new View.OnClickListener() {
	
		@Override
		public void onClick(View v) {
			if(c11.isChecked()){
				spn11.setEnabled(true);
				textfilterAir.setEnabled(true);		   
				   

							
							for(int i = 1 ; i<=10 ; i++){
								amountfilterAir.add(String.valueOf(i));
								}
							ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, filterAirname);
							textfilterAir.setThreshold(1);
					         
							textfilterAir.setAdapter(adapter);
					        
							textfilterAir.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
								
					            public void onItemSelected(AdapterView<?> adapterView, 
					          	View view, int i, long l) { 
					          	// TODO Auto-generated method stub    	
					            	}
					            public void onNothingSelected(AdapterView<?> arg0) {
									// TODO Auto-generated method stub
					            	InputMethodManager imm = (InputMethodManager) getSystemService(
					                        INPUT_METHOD_SERVICE);
					                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
								} 
			
				      });

							textfilterAir.setOnItemClickListener(new  OnItemClickListener(){
									@Override
									public void onItemClick(AdapterView<?> arg0, View arg1, int i, long arg3) {
										// TODO Auto-generated method stub
										
										String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201309160008' and ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
						            	ResultSet rs = con.selectData(sql);
						            	try {
											while(rs.next()){   
												//et3.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
								            	list11 = rs.getString("ItemName")+",";
								            	//price3 = rs.getString("LastBuyPrice")+",";
								            	t11 = Integer.parseInt(rs.getString("Duration"));
								            	str11 = rs.getString("LastBuyPrice");
												}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
										}    	
										 
						            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
										 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i));
										
										 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountfilterAir);
											empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
											spn11.setAdapter(empolyeeAdapter);
											
											spn11.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long l) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountfilterAir.get(i));
									            	double ans = div * Double.parseDouble(str11);
									            	
									            	et11.setText(df.format(ans));
									                price11 = String.valueOf(ans)+",";
									            	k = ans;
									            	
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
									
									}

					            });

			}
			else {
				k = 0;
				t11 = 0;
				filterAirprice.clear();
				filterAirname.clear();
				 textfilterAir.setEnabled(false);
				 spn11.setEnabled(false);
				 textfilterAir.setText("");
				et11.setText("");
				list11 = "";
				price11 = "";
				}
        }
    });	
		
		
	
} 
	
*/
	
	
private void filterAir() {
		
	
			c11.setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
	    			if(c11.isChecked()){
	    				filterAirprice.clear();
	    				filterAirname.clear();
	    				filterAirtime.clear();
	    				
	    				 spn11.setEnabled(true);
	    				textfilterAir.setEnabled(true);
						 rs = con.selectData("SELECT *,ItemCode+' '+ItemName AS ItemCo FROM Item WHERE ItemGroupCode = '105201309160008' ");		   

									try {
										while(rs.next()){          
											filterAirprice.add(rs.getString("LastBuyPrice"));	
											filterAirname.add(rs.getString("ItemCo"));	
											filterAirtime.add(rs.getString("Duration"));
		
											}
									} catch (SQLException e) {
										// TODO Auto-generated catch block
										e.printStackTrace();
									}   
									
									for(int i = 1 ; i<=10 ; i++){
										amountfilterAir.add(String.valueOf(i));
										}
									
									ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, filterAirname);
									textfilterAir.setThreshold(1);
							         
									textfilterAir.setAdapter(adapter);
							         
									textfilterAir.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
											
								            public void onItemSelected(AdapterView<?> adapterView, 
								          	View view, int i, long l) { 
								          	// TODO Auto-generated method stub    	
								            	}
								            public void onNothingSelected(AdapterView<?> arg0) {
												// TODO Auto-generated method stub
								            	InputMethodManager imm = (InputMethodManager) getSystemService(
								                        INPUT_METHOD_SERVICE);
								                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
											} 
						
							      });
									textfilterAir.setOnItemClickListener(new  OnItemClickListener(){

											@Override
											public void onItemClick(
													AdapterView<?> arg0,
													View arg1, int i,
													long arg3) {
												// TODO Auto-generated method stub
												
												String sql = "SELECT *,ItemCode+' '+ItemName AS ItemCo FROM Item WHERE ItemGroupCode = '105201309160008' and ItemCode+' '+ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
								            	ResultSet rs = con.selectData(sql);
								            	try {
													while(rs.next()){   
														//et10.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
										            	list11 = rs.getString("ItemCo")+",";
										            //	price10 = rs.getString("LastBuyPrice")+",";
										            	t11 = Integer.parseInt(rs.getString("Duration"));
										            	str11 = rs.getString("LastBuyPrice");
														}
												} catch (SQLException e) {
													// TODO Auto-generated catch block
													e.printStackTrace();
												} 
								            	
								            	
								            	 Toast.makeText(HoleActivity_edit.this,"list11 = "+list11, Toast.LENGTH_SHORT).show();
								            	 Toast.makeText(HoleActivity_edit.this,"list11_2 = "+filterAirname.get(i).toString(), Toast.LENGTH_SHORT).show();
								            	
								            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
												 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i));
												
												 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountfilterAir);
													empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
													spn11.setAdapter(empolyeeAdapter);
													
													spn11.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
														
											            public void onItemSelected(AdapterView<?> adapterView, 
											          	View view, int i, long l) { 
											          	// TODO Auto-generated method stub
											            	double div = Double.parseDouble(amountfilterAir.get(i));
											            	double ans = div * Double.parseDouble(str11);
											            	
											            	et11.setText(df.format(ans));
											                price11 = String.valueOf(ans)+",";
											            	k = ans;
											            	
											            	}
											            public void onNothingSelected(AdapterView<?> arg0) {
															// TODO Auto-generated method stub

														} 
									
										      });
											
											}

										
							            	
							            });
		
	    			}
	    			else {
	    				t11 = 0;
	    				k = 0;
	    				filterAirprice.clear();
	    				filterAirname.clear();
	    				textfilterAir.setEnabled(false);
	    				textfilterAir.setText("");
	    				et11.setText("");
	    				 list11 = "";
	    				 price11 = "";
	    				}
	            }
	        });	
				
				
			
		}	 
	
	
/*	
private void liquor() {

	
	c12.setOnClickListener(new View.OnClickListener() {
	
		@Override
		public void onClick(View v) {
			if(c12.isChecked()){
				spn12.setEnabled(true);
				textliquor.setEnabled(true);		   
				   

							
							for(int i = 1 ; i<=10 ; i++){
								amountliquor.add(String.valueOf(i));
								}
							ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, liquorname);
							textliquor.setThreshold(1);
					         
							textliquor.setAdapter(adapter);
					        
							textliquor.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
								
					            public void onItemSelected(AdapterView<?> adapterView, 
					          	View view, int i, long l) { 
					          	// TODO Auto-generated method stub    	
					            	}
					            public void onNothingSelected(AdapterView<?> arg0) {
									// TODO Auto-generated method stub
					            	InputMethodManager imm = (InputMethodManager) getSystemService(
					                        INPUT_METHOD_SERVICE);
					                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
								} 
			
				      });

							textliquor.setOnItemClickListener(new  OnItemClickListener(){
									@Override
									public void onItemClick(AdapterView<?> arg0, View arg1, int i, long arg3) {
										// TODO Auto-generated method stub
										
										String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201310110015' and ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
						            	ResultSet rs = con.selectData(sql);
						            	try {
											while(rs.next()){   
												//et3.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
								            	list12 = rs.getString("ItemName")+",";
								            	//price3 = rs.getString("LastBuyPrice")+",";
								            	t12 = Integer.parseInt(rs.getString("Duration"));
								            	str12 = rs.getString("LastBuyPrice");
												}
										} catch (SQLException e) {
											// TODO Auto-generated catch block
											e.printStackTrace();
										}    	
										 
						            	  Toast.makeText(HoleActivity_edit.this,arg0.getItemAtPosition(i).toString(), Toast.LENGTH_SHORT).show();
										 Log.i("AutocompleteContacts", "Position:"+i+" Month:"+arg0.getItemAtPosition(i));
										
										 ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountliquor);
											empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
											spn12.setAdapter(empolyeeAdapter);
											
											spn12.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
												
									            public void onItemSelected(AdapterView<?> adapterView, 
									          	View view, int i, long ll) { 
									          	// TODO Auto-generated method stub
									            	double div = Double.parseDouble(amountliquor.get(i));
									            	double ans = div * Double.parseDouble(str12);
									            	
									            	et12.setText(df.format(ans));
									                price12 = String.valueOf(ans)+",";
									            	l = ans;
									            	
									            	}
									            public void onNothingSelected(AdapterView<?> arg0) {
													// TODO Auto-generated method stub

												} 
							
								      });
									
									}

					            });

			}
			else {
				l = 0;
				t12 = 0;
				liquorprice.clear();
				liquorname.clear();
				 textliquor.setEnabled(false);
				 spn12.setEnabled(false);
				 textliquor.setText("");
				et12.setText("");
				list12 = "";
				price12 = "";
				}
        }
    });	
		
		
	
}

*/


@SuppressLint("NewApi")
private void liquor() {
	
	 c12.setOnClickListener(new View.OnClickListener() {
			String str;
			@Override
			public void onClick(View v) {
    			if(c12.isChecked()){
    				
    				liquorprice.clear();
    				liquorname.clear();
    				liquortime.clear();
    				
    				spn12.setEnabled(true);
    				textliquor.setEnabled(true);

    				 rs = con.selectData("SELECT * FROM Item WHERE ItemGroupCode = '105201310110016' ");		   
						try {
							while(rs.next()){          
								liquorprice.add(rs.getString("LastBuyPrice"));	
								liquorname.add(rs.getString("ItemName"));	
								liquortime.add(rs.getString("Duration"));
								}
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}      

					for(int i = 1 ; i<=10 ; i++){
						amountliquor.add(String.valueOf(i));
					}
					
					ArrayAdapter<String> adapter = new ArrayAdapter<String>(HoleActivity_edit.this, android.R.layout.simple_dropdown_item_1line, liquorname);
				    textliquor.setThreshold(1);
				    textliquor.setAdapter(adapter);
				    textliquor.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
						
			            public void onItemSelected(AdapterView<?> adapterView, 
			          	View view, int i, long l) { 
			          	// TODO Auto-generated method stub    	
			            	}
			            public void onNothingSelected(AdapterView<?> arg0) {
							// TODO Auto-generated method stub
			            	InputMethodManager imm = (InputMethodManager) getSystemService(
			                        INPUT_METHOD_SERVICE);
			                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
						} 
	
		      });
				textliquor.setOnItemClickListener(new  OnItemClickListener(){
						@Override
						public void onItemClick(AdapterView<?> arg0, View arg1, int i, long arg3) {
							// TODO Auto-generated method stub
							
							String sql = "SELECT * FROM Item WHERE ItemGroupCode = '105201310110016' and ItemName = '"+arg0.getItemAtPosition(i).toString()+"'  ";
			            	ResultSet rs = con.selectData(sql);
			            	try {
								while(rs.next()){   
									//et3.setText(df.format(Double.parseDouble(rs.getString("LastBuyPrice"))));
					            	list12 = rs.getString("ItemName")+",";
					            	//price3 = rs.getString("LastBuyPrice")+",";
					            	t12 = Integer.parseInt(rs.getString("Duration"));
					            	str = rs.getString("LastBuyPrice");
									}
							} catch (SQLException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}    	
			            	
					ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountliquor);
					empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
					spn12.setAdapter(empolyeeAdapter);
		
					spn12.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
						
			            public void onItemSelected(AdapterView<?> adapterView, 
			          	View view, int i, long ll) { 
			          	// TODO Auto-generated method stub
			            	double div = Double.parseDouble(amountliquor.get(i));
			            	double ans = div * Double.parseDouble(str);
			            	
			            	et12.setText(df.format(ans));
			                price12 = String.valueOf(ans)+",";
			            	l = ans;
			            	
			            	}
			            public void onNothingSelected(AdapterView<?> arg0) {
							// TODO Auto-generated method stub

						} 
						
				      });
					
					}

	            });

}
    			else {
    					l = 0;
	    				t12 = 0;
	    				liquorprice.clear();
	    				liquorname.clear();
	    				textliquor.setEnabled(false);
					    textliquor.setText("");
					    amountliquor.clear();
	    				et12.setText("");
	    				list12 = "";
	    				price12 = "";
	    				spn12.setEnabled(false);
	
    				}
            }
        });


		
	}	





private void compress() {
	

	
	 c13 = ( CheckBox ) this.findViewById ( R.id.check13);			
	 et13 = ( TextView ) this.findViewById ( R.id.result13);
	 
	 c13.setOnClickListener(new View.OnClickListener() {
			String str;
			@Override
			public void onClick(View v) {
    			if(c13.isChecked()){
    				
    				 spn13.setEnabled(true);
		
    				 rs = con.selectData("SELECT * FROM Item WHERE OID = '104201310100002' ");	
					try {

						    rs.next();
						    str = rs.getString("LastBuyPrice");
						    list13 = rs.getString("ItemName")+",";
						   // price13 = rs.getString("LastBuyPrice")+",";
						    t13 = Integer.parseInt(rs.getString("Duration").toString());
	
					} catch (SQLException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}  
					
					for(int i = 1 ; i<=10 ; i++){
						amountcompress.add(String.valueOf(i));
						}
						
						ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountcompress);
						empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
						spn13.setAdapter(empolyeeAdapter);
						
						spn13.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
							
				            public void onItemSelected(AdapterView<?> adapterView, 
				          	View view, int i, long l) { 
				          	// TODO Auto-generated method stub
				            	double div = Double.parseDouble(amountcompress.get(i));
				            	double ans = div * Double.parseDouble(str);

									et13.setText(df.format(ans));
									price13 = String.valueOf(ans)+",";
									m = ans;
				            	}
				            public void onNothingSelected(AdapterView<?> arg0) {
								// TODO Auto-generated method stub

							} 
		
			      });
					
			
    				}
    			else {
    				t14 = 0;
    				m = 0;
    				et13.setText(""); 
    				 list13 = "";
    				 price13 = "";
    				 spn13.setEnabled(false);
    				 amountcompress.clear();
    				}
            }
        });
} 
	 
private void color() {
	
	
	 
		 c14 = ( CheckBox ) this.findViewById ( R.id.check14);			
		 et14 = ( TextView ) this.findViewById ( R.id.result14);
		 
		 c14.setOnClickListener(new View.OnClickListener() {
				String str;
				@Override
				public void onClick(View v) {
	    			if(c14.isChecked()){
	    				
	    				spn14.setEnabled(true);
			
	    				 rs = con.selectData("SELECT * FROM Item WHERE OID = '104201310110007' ");	
						try {

							    rs.next();
							    str = rs.getString("LastBuyPrice");
							    list14 = rs.getString("ItemName")+",";
							  //  price14 = rs.getString("LastBuyPrice")+",";
							    t14 = Integer.parseInt(rs.getString("Duration").toString());
		
						} catch (SQLException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}  
						for(int i = 1 ; i<=10 ; i++){
							amountcolor.add(String.valueOf(i));
							}
							
							ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(HoleActivity_edit.this,android.R.layout.simple_spinner_item,amountcolor);
							empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
							spn14.setAdapter(empolyeeAdapter);
							
							spn14.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 
								
					            public void onItemSelected(AdapterView<?> adapterView, 
					          	View view, int i, long l) { 
					          	// TODO Auto-generated method stub
					            	double div = Double.parseDouble(amountcolor.get(i));
					            	double ans = div * Double.parseDouble(str);

										et14.setText(df.format(ans));
										price14 = String.valueOf(ans)+",";
										n = ans;
					            	}
					            public void onNothingSelected(AdapterView<?> arg0) {
									// TODO Auto-generated method stub

								} 
			
				      });
						
						
				
	    				}
	    			else {
	    				t14 = 0;
	    				n = 0;
	    				et14.setText("");
	    				 list14 = "";
	    				 price14 = "";
	    				 spn14.setEnabled(false);
	    				 amountcolor.clear();
	    				}
	            }
	        });
}






	
	

public void selectDis(){
	
	//	String tusTmp = getIntent().getExtras().getString("Status");	
		  spnDis = (Spinner) findViewById(R.id.selectDiscount);
		
		
		
		
		  
		Dis.add(DiscountNameEDT);
		Dis.add("����");
		Dis.add("�.�.�.");
		Dis.add("��ǹŴ˹���ҹ");
		 	
		
		
	ArrayAdapter<String> empolyeeAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,Dis);
	empolyeeAdapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
	spnDis.setAdapter(empolyeeAdapter);

	spnDis.setOnItemSelectedListener(new  AdapterView.OnItemSelectedListener() { 

	public void onItemSelected(AdapterView<?> adapterView, 
		View view, int i, long l) { 
		// TODO Auto-generated method stub
		
		
		
		DisCt = Dis.get(i);
		
		 
		
		}
	public void onNothingSelected(AdapterView<?> arg0) {
		// TODO Auto-generated method stub
		Toast.makeText(HoleActivity_edit.this,
					String.valueOf("ʶҹ��ա������¹�ŧ����"),
						Toast.LENGTH_SHORT).show();
	} 

	});
	
	}

////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	// TODO Auto-generated method stub
	super.onActivityResult(requestCode, resultCode, data);
	Log.i("Get data", requestCode+"");

	switch (requestCode) {
	case services_edit.REQUEST_CODE:
		 
		final AlertDialog.Builder dDialog = new AlertDialog.Builder(this);
		
		timeSer = data.getStringExtra("time");
		sumSer = data.getStringExtra("Money");
		listSer = data.getStringExtra("list");
		priceSer = data.getStringExtra("price");
		

		arr = listSer.split(",");
		arr2 = priceSer.split(",");
		
	
		  Toast.makeText(HoleActivity_edit.this, timeSer+" "+sumSer+" "+listSer+" "+priceSer, Toast.LENGTH_LONG).show();
		  

		  Sum.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					
					if(et15.getText().toString().equals("")){
						p = 0;
					}else{
					p = Double.parseDouble(et15.getText().toString());
					}
				
					
					
					///////////  ��ǹ ����� ////////////
				
					
					
							//////////////  ��ǹŴ�ٻͧ	
								sumDiscNull = disc.getText().toString();
			    				
			    				if(sumDiscNull.equals(null)||sumDiscNull.equals("")){
			    					sumDisc = "0";
			    				}else{
			    					sumDisc = sumDiscNull;
			    				}
			    				sumDisBTHNull = disBTH.getText().toString();
			    				
			    				if(sumDisBTHNull.equals(null)||sumDisBTHNull.equals("")){
			    					sumDisBTH = "0";
			    				}else{
			    					
			    					sumDisBTH = sumDisBTHNull;
			    				}
			    				
			    			////////////////���ǹŴ VIP
			    				VIPcode = prom.getText().toString();
			    				
			    				
			    				
					
					timeSum = t1+t2+t3+t4+t5+t6+t7+t8+t9+t10+t11+t12+t13+t14+Integer.parseInt(timeSer);
					timeSum = timeSum+0;
					Toast.makeText(HoleActivity_edit.this, "All time is : "+timeSum, Toast.LENGTH_SHORT).show();
					
					amount = a+b+c+d+e+f+g+h+ii+jj+k+l+m+n+o+p+Double.parseDouble(sumSer);
					SumAmount.setText(String.valueOf(df.format(amount)));
					
					finalSum = (amount-Integer.parseInt(sumDisBTH))-(((amount-Integer.parseInt(sumDisBTH))*Integer.parseInt(sumDisc))/100);
					

					TextSum.setText(String.valueOf(df.format(finalSum)));	


				}
				});
		  
		  btn1.setOnClickListener(new View.OnClickListener() {
				public void onClick(View v) {
					
		/**
					rs2 = con.selectData("SELECT MAX(ServiceID) AS maxid FROM CustomerCar WHERE ServiceID = '"+RegisterIDEDT+"' ");
   				try {
   					rs2.next();
   					ServiceIDsent = rs2.getString("maxid");
   				} catch (SQLException e1) {
   					// TODO Auto-generated catch block
   					e1.printStackTrace();
   				}
   			**/	
   				
   				
   				if(et15.getText().toString().equals("")){
   					price15 = "-,";
	   				list15 = "-,";
				}else{
					price15 = et15.getText().toString()+",";
	   				list15 = orther1.getText().toString()+",";
				}
   		
					price16 = "-,";
	   				list16 = "-,";
		
			
					price17 = "-,";
	   				list17 = "-,";
			
				
				
				
					 
					String sql = "UPDATE DataService " +
							"SET List='"+list1+list2+list3+list4+list5+list6+list7+list8+list9+
							list10+list11+list12+list13+list14+listSer+list15+list16+list17+"'" +
									",price='"+price1+price2+price3+price4+price5+price6+price7+price8+price9+
									price10+price11+price12+price13+price14+priceSer+price15+price16+price17+"'" +
											",VIPcode='"+VIPcode+"',Discount='"+sumDisc+"',amount='"+amount+"'" +
													",Sum='"+finalSum+"',sumTime='"+timeSum+"',date='"+mDay+"/"+(1+mMonth)+"/"+mYear+"'" +
										",DiscountName='"+DisCt+"',PriceBTH='"+sumDisBTH+"',checkOrther='"+checkOrther1+"' " +
													"WHERE ServiceID ='"+ServiceIDEDT+"' ";
						
   				
					
				if(con.addData(sql)){	 
				Toast.makeText(HoleActivity_edit.this, "Inserted data successfully", Toast.LENGTH_SHORT).show();
				Toast.makeText(HoleActivity_edit.this, ServiceIDEDT, Toast.LENGTH_SHORT).show();
				Intent newActivityAdd = new Intent(HoleActivity_edit.this,Card_Edit.class);
				newActivityAdd.putExtra("ServiceID", ServiceIDEDT);
				newActivityAdd.putExtra("name", NameInput);
				newActivityAdd.putExtra("CompanyS", company);
				startActivity(newActivityAdd);
				
				}else{
			    Toast.makeText(HoleActivity_edit.this, "Inserted data fail", Toast.LENGTH_SHORT).show();
			  
				}
				
				}
				
		 });
		 
	}
}



////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
	
	@Override
	public void onBackPressed() {
	  
	        new AlertDialog.Builder(this)
	        .setTitle("¡��ԡ��÷���¡��")
	        .setMessage("��Ѻ�˹����ѡ")
	                .setNegativeButton(android.R.string.yes, new DialogInterface.OnClickListener() {

	                    public void onClick(DialogInterface arg0, int arg1) {
	                        Intent newActivity = new Intent(getApplicationContext(),MainActivity.class);	                          
	                        newActivity.putExtra("name", NameInput);
	                        newActivity.putExtra("CompanyS", company);
	                        startActivity(newActivity);
	                        finish();
	                        overridePendingTransition(R.layout.fadeendout,R.layout.fadeendin);
	                    }
	                })
	                .setPositiveButton(android.R.string.no, null).create().show();
	    

	} 

	
@Override


	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
